mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-07-24 21:39:14 +02:00
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
package db
|
|
|
|
import (
|
|
"github.com/pocketbase/dbx"
|
|
"htwkalender/model"
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func Test_buildIcalQueryForModules(t *testing.T) {
|
|
type args struct {
|
|
modules []model.FeedCollection
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
want dbx.Expression
|
|
}{
|
|
{
|
|
name: "empty modules",
|
|
args: args{modules: []model.FeedCollection{}},
|
|
want: dbx.HashExp{},
|
|
},
|
|
{
|
|
name: "one module",
|
|
args: args{modules: []model.FeedCollection{{Name: "test", Course: "test"}}},
|
|
want: dbx.And(dbx.HashExp{"Name": "test"}, dbx.HashExp{"course": "test"}),
|
|
},
|
|
{
|
|
name: "two modules",
|
|
args: args{modules: []model.FeedCollection{{Name: "test", Course: "test"}, {Name: "test2", Course: "test2"}}},
|
|
want: dbx.Or(dbx.And(dbx.HashExp{"Name": "test"}, dbx.HashExp{"course": "test"}), dbx.And(dbx.HashExp{"Name": "test2"}, dbx.HashExp{"course": "test2"})),
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := buildIcalQueryForModules(tt.args.modules); !reflect.DeepEqual(got, tt.want) {
|
|
t.Errorf("buildIcalQueryForModules() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|