mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 19:14:23 +00:00
41e1a7cc7b
* one concurrent task * disable spooler * fix: improve concurrency in spooler * fix: dont block lock * fix: break if lock failed * fix: check if handler is working * fix: worker id * fix: test * fix: use limit for spoolers configured in startup.yaml * fix test * fix: factory * fix(key): only reduce if not expired * fix(searchQueryFactory): check for string-slice in aggregateID * fix(migrations): combine migrations * fix: allow saving multiple objects in one request * fix(eventstore): logging * fix(eventstore): rethink insert i locks table * fix: ignore failed tests for the moment * fix: tuubel * fix: for tests in io * fix: ignore tests for io * fix: rename concurrent tasks to workers * fix: incomment tests and remove some tests * fix: refert changes for io * refactor(eventstore): combine types of sql in one file * refactor(eventstore): logs, TODO's, tests * fix(eventstore): sql package * test(eventstore): add tests for search query factory * chore: logs * fix(spooler): optimize lock query chore(migrations): rename locks.object_type to view_name chore(migrations): refactor migrations * test: incomment tests * fix: rename PrepareSaves to PrepareBulkSave * chore: go dependencies * fix(migrations): add id in events table * refactor(lock): less magic numbers Co-authored-by: Livio Amstutz <livio.a@gmail.com>
66 lines
1.6 KiB
Go
66 lines
1.6 KiB
Go
package models
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func TestSearchQuery_setFilter(t *testing.T) {
|
|
type fields struct {
|
|
query *SearchQuery
|
|
}
|
|
type args struct {
|
|
filters []*Filter
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
fields fields
|
|
args args
|
|
want *SearchQuery
|
|
}{
|
|
{
|
|
name: "set idFilter",
|
|
fields: fields{query: NewSearchQuery()},
|
|
args: args{filters: []*Filter{
|
|
{field: Field_AggregateID, operation: Operation_Equals, value: "hodor"},
|
|
}},
|
|
want: &SearchQuery{Filters: []*Filter{
|
|
{field: Field_AggregateID, operation: Operation_Equals, value: "hodor"},
|
|
}},
|
|
},
|
|
{
|
|
name: "overwrite idFilter",
|
|
fields: fields{query: NewSearchQuery()},
|
|
args: args{filters: []*Filter{
|
|
{field: Field_AggregateID, operation: Operation_Equals, value: "hodor"},
|
|
{field: Field_AggregateID, operation: Operation_Equals, value: "ursli"},
|
|
}},
|
|
want: &SearchQuery{Filters: []*Filter{
|
|
{field: Field_AggregateID, operation: Operation_Equals, value: "ursli"},
|
|
}},
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got := tt.fields.query
|
|
for _, filter := range tt.args.filters {
|
|
got = got.setFilter(filter)
|
|
}
|
|
for _, wantFilter := range tt.want.Filters {
|
|
found := false
|
|
for _, gotFilter := range got.Filters {
|
|
if gotFilter.field == wantFilter.field {
|
|
found = true
|
|
if !reflect.DeepEqual(wantFilter, gotFilter) {
|
|
t.Errorf("filter not as expected: want: %v got %v", wantFilter, gotFilter)
|
|
}
|
|
}
|
|
}
|
|
if !found {
|
|
t.Errorf("filter field %v not found", wantFilter.field)
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}
|