zitadel/internal/eventstore/search_query_test.go

699 lines
18 KiB
Go
Raw Normal View History

2020-09-24 06:52:10 +00:00
package eventstore
import (
2020-10-06 19:28:09 +00:00
"math"
2020-09-24 06:52:10 +00:00
"reflect"
"testing"
"github.com/caos/zitadel/internal/errors"
"github.com/caos/zitadel/internal/eventstore/repository"
2020-09-24 06:52:10 +00:00
)
func testAddQuery(queryFuncs ...func(*SearchQuery) *SearchQuery) func(*SearchQueryBuilder) *SearchQueryBuilder {
return func(builder *SearchQueryBuilder) *SearchQueryBuilder {
query := builder.AddQuery()
for _, queryFunc := range queryFuncs {
queryFunc(query)
}
return query.Builder()
}
}
2020-12-01 13:44:19 +00:00
func testSetColumns(columns Columns) func(factory *SearchQueryBuilder) *SearchQueryBuilder {
return func(factory *SearchQueryBuilder) *SearchQueryBuilder {
2020-09-24 06:52:10 +00:00
factory = factory.Columns(columns)
return factory
}
}
2020-12-01 13:44:19 +00:00
func testSetLimit(limit uint64) func(factory *SearchQueryBuilder) *SearchQueryBuilder {
return func(factory *SearchQueryBuilder) *SearchQueryBuilder {
2020-09-24 06:52:10 +00:00
factory = factory.Limit(limit)
return factory
}
}
func testOr(queryFuncs ...func(*SearchQuery) *SearchQuery) func(*SearchQuery) *SearchQuery {
return func(query *SearchQuery) *SearchQuery {
subQuery := query.Or()
for _, queryFunc := range queryFuncs {
queryFunc(subQuery)
}
return subQuery
2020-09-24 06:52:10 +00:00
}
}
func testSetAggregateTypes(types ...AggregateType) func(*SearchQuery) *SearchQuery {
return func(query *SearchQuery) *SearchQuery {
query = query.AggregateTypes(types...)
return query
2020-09-24 06:52:10 +00:00
}
}
func testSetSequence(sequence uint64) func(*SearchQuery) *SearchQuery {
return func(query *SearchQuery) *SearchQuery {
query = query.SequenceGreater(sequence)
return query
2020-09-24 06:52:10 +00:00
}
}
func testSetAggregateIDs(aggregateIDs ...string) func(*SearchQuery) *SearchQuery {
return func(query *SearchQuery) *SearchQuery {
query = query.AggregateIDs(aggregateIDs...)
return query
2020-09-24 06:52:10 +00:00
}
}
func testSetEventTypes(eventTypes ...EventType) func(*SearchQuery) *SearchQuery {
return func(query *SearchQuery) *SearchQuery {
query = query.EventTypes(eventTypes...)
return query
}
}
func testSetResourceOwner(resourceOwner string) func(*SearchQueryBuilder) *SearchQueryBuilder {
return func(builder *SearchQueryBuilder) *SearchQueryBuilder {
builder = builder.ResourceOwner(resourceOwner)
return builder
}
}
func testSetSortOrder(asc bool) func(*SearchQueryBuilder) *SearchQueryBuilder {
return func(query *SearchQueryBuilder) *SearchQueryBuilder {
2020-09-24 06:52:10 +00:00
if asc {
query = query.OrderAsc()
2020-09-24 06:52:10 +00:00
} else {
query = query.OrderDesc()
2020-09-24 06:52:10 +00:00
}
return query
2020-09-24 06:52:10 +00:00
}
}
func TestSearchQueryFactorySetters(t *testing.T) {
type args struct {
columns Columns
setters []func(*SearchQueryBuilder) *SearchQueryBuilder
2020-09-24 06:52:10 +00:00
}
tests := []struct {
name string
args args
2020-12-01 13:44:19 +00:00
res *SearchQueryBuilder
2020-09-24 06:52:10 +00:00
}{
{
name: "New factory",
args: args{
columns: ColumnsEvent,
2020-09-24 06:52:10 +00:00
},
2020-12-01 13:44:19 +00:00
res: &SearchQueryBuilder{
columns: repository.Columns(ColumnsEvent),
2020-09-24 06:52:10 +00:00
},
},
{
name: "set columns",
args: args{
2020-12-01 13:44:19 +00:00
setters: []func(*SearchQueryBuilder) *SearchQueryBuilder{testSetColumns(repository.ColumnsMaxSequence)},
2020-09-24 06:52:10 +00:00
},
2020-12-01 13:44:19 +00:00
res: &SearchQueryBuilder{
2020-10-06 19:28:09 +00:00
columns: repository.ColumnsMaxSequence,
2020-09-24 06:52:10 +00:00
},
},
{
name: "set limit",
args: args{
2020-12-01 13:44:19 +00:00
setters: []func(*SearchQueryBuilder) *SearchQueryBuilder{testSetLimit(100)},
2020-09-24 06:52:10 +00:00
},
2020-12-01 13:44:19 +00:00
res: &SearchQueryBuilder{
2020-09-24 06:52:10 +00:00
limit: 100,
},
},
{
name: "set sequence",
args: args{
setters: []func(*SearchQueryBuilder) *SearchQueryBuilder{testAddQuery(testSetSequence(90))},
2020-09-24 06:52:10 +00:00
},
2020-12-01 13:44:19 +00:00
res: &SearchQueryBuilder{
queries: []*SearchQuery{
{
eventSequence: 90,
},
},
2020-09-24 06:52:10 +00:00
},
},
{
name: "set aggregateIDs",
args: args{
setters: []func(*SearchQueryBuilder) *SearchQueryBuilder{testAddQuery(testSetAggregateIDs("1235", "09824"))},
2020-09-24 06:52:10 +00:00
},
2020-12-01 13:44:19 +00:00
res: &SearchQueryBuilder{
queries: []*SearchQuery{
{
aggregateIDs: []string{"1235", "09824"},
},
},
2020-09-24 06:52:10 +00:00
},
},
{
name: "set eventTypes",
args: args{
setters: []func(*SearchQueryBuilder) *SearchQueryBuilder{testAddQuery(testSetEventTypes("user.created", "user.updated"))},
2020-09-24 06:52:10 +00:00
},
2020-12-01 13:44:19 +00:00
res: &SearchQueryBuilder{
queries: []*SearchQuery{
{
eventTypes: []EventType{"user.created", "user.updated"},
},
},
2020-09-24 06:52:10 +00:00
},
},
{
name: "set resource owner",
args: args{
2020-12-01 13:44:19 +00:00
setters: []func(*SearchQueryBuilder) *SearchQueryBuilder{testSetResourceOwner("hodor")},
2020-09-24 06:52:10 +00:00
},
2020-12-01 13:44:19 +00:00
res: &SearchQueryBuilder{
2020-09-24 06:52:10 +00:00
resourceOwner: "hodor",
},
},
{
name: "default search query",
args: args{
setters: []func(*SearchQueryBuilder) *SearchQueryBuilder{testAddQuery(testSetAggregateTypes("user"), testSetAggregateIDs("1235", "024")), testSetSortOrder(false)},
2020-09-24 06:52:10 +00:00
},
2020-12-01 13:44:19 +00:00
res: &SearchQueryBuilder{
desc: true,
queries: []*SearchQuery{
{
aggregateTypes: []AggregateType{"user"},
aggregateIDs: []string{"1235", "024"},
},
},
2020-09-24 06:52:10 +00:00
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
builder := NewSearchQueryBuilder(tt.args.columns)
2020-09-24 06:52:10 +00:00
for _, setter := range tt.args.setters {
builder = setter(builder)
2020-09-24 06:52:10 +00:00
}
assertBuilder(t, tt.res, builder)
2020-09-24 06:52:10 +00:00
})
}
}
func TestSearchQueryFactoryBuild(t *testing.T) {
type args struct {
columns Columns
setters []func(*SearchQueryBuilder) *SearchQueryBuilder
2020-09-24 06:52:10 +00:00
}
type res struct {
isErr func(err error) bool
2020-09-30 08:00:05 +00:00
query *repository.SearchQuery
2020-09-24 06:52:10 +00:00
}
tests := []struct {
name string
args args
res res
}{
{
name: "no aggregate types",
args: args{
columns: ColumnsEvent,
setters: []func(*SearchQueryBuilder) *SearchQueryBuilder{},
2020-09-24 06:52:10 +00:00
},
res: res{
isErr: errors.IsPreconditionFailed,
query: nil,
},
},
{
name: "invalid column (too low)",
args: args{
columns: ColumnsEvent,
2020-12-01 13:44:19 +00:00
setters: []func(*SearchQueryBuilder) *SearchQueryBuilder{
2020-09-24 06:52:10 +00:00
testSetColumns(Columns(-1)),
testAddQuery(testSetAggregateTypes("user")),
2020-09-24 06:52:10 +00:00
},
},
res: res{
isErr: errors.IsPreconditionFailed,
},
},
{
name: "invalid column (too high)",
args: args{
columns: ColumnsEvent,
2020-12-01 13:44:19 +00:00
setters: []func(*SearchQueryBuilder) *SearchQueryBuilder{
2020-10-06 19:28:09 +00:00
testSetColumns(math.MaxInt32),
testAddQuery(testSetAggregateTypes("uesr")),
2020-09-24 06:52:10 +00:00
},
},
res: res{
isErr: errors.IsPreconditionFailed,
},
},
{
name: "filter aggregate type",
args: args{
columns: ColumnsEvent,
setters: []func(*SearchQueryBuilder) *SearchQueryBuilder{
testAddQuery(testSetAggregateTypes("user")),
},
2020-09-24 06:52:10 +00:00
},
res: res{
isErr: nil,
2020-09-30 08:00:05 +00:00
query: &repository.SearchQuery{
2020-10-06 19:28:09 +00:00
Columns: repository.ColumnsEvent,
2020-09-24 06:52:10 +00:00
Desc: false,
Limit: 0,
Filters: [][]*repository.Filter{
{
repository.NewFilter(repository.FieldAggregateType, repository.AggregateType("user"), repository.OperationEquals),
},
2020-09-24 06:52:10 +00:00
},
},
},
},
{
name: "filter aggregate types",
args: args{
columns: ColumnsEvent,
setters: []func(*SearchQueryBuilder) *SearchQueryBuilder{
testAddQuery(testSetAggregateTypes("user", "org")),
},
2020-09-24 06:52:10 +00:00
},
res: res{
isErr: nil,
2020-09-30 08:00:05 +00:00
query: &repository.SearchQuery{
2020-10-06 19:28:09 +00:00
Columns: repository.ColumnsEvent,
2020-09-24 06:52:10 +00:00
Desc: false,
Limit: 0,
Filters: [][]*repository.Filter{
{
repository.NewFilter(repository.FieldAggregateType, []repository.AggregateType{"user", "org"}, repository.OperationIn),
},
2020-09-24 06:52:10 +00:00
},
},
},
},
{
name: "filter aggregate type, limit, desc",
args: args{
columns: ColumnsEvent,
2020-12-01 13:44:19 +00:00
setters: []func(*SearchQueryBuilder) *SearchQueryBuilder{
2020-09-24 06:52:10 +00:00
testSetLimit(5),
testSetSortOrder(false),
testAddQuery(
testSetSequence(100),
testSetAggregateTypes("user"),
),
2020-09-24 06:52:10 +00:00
},
},
res: res{
isErr: nil,
2020-09-30 08:00:05 +00:00
query: &repository.SearchQuery{
2020-10-06 19:28:09 +00:00
Columns: repository.ColumnsEvent,
2020-09-24 06:52:10 +00:00
Desc: true,
Limit: 5,
Filters: [][]*repository.Filter{
{
repository.NewFilter(repository.FieldAggregateType, repository.AggregateType("user"), repository.OperationEquals),
repository.NewFilter(repository.FieldSequence, uint64(100), repository.OperationLess),
},
2020-09-24 06:52:10 +00:00
},
},
},
},
{
name: "filter aggregate type, limit, asc",
args: args{
columns: ColumnsEvent,
2020-12-01 13:44:19 +00:00
setters: []func(*SearchQueryBuilder) *SearchQueryBuilder{
2020-09-24 06:52:10 +00:00
testSetLimit(5),
testSetSortOrder(true),
testAddQuery(
testSetSequence(100),
testSetAggregateTypes("user"),
),
2020-09-24 06:52:10 +00:00
},
},
res: res{
isErr: nil,
2020-09-30 08:00:05 +00:00
query: &repository.SearchQuery{
2020-10-06 19:28:09 +00:00
Columns: repository.ColumnsEvent,
2020-09-24 06:52:10 +00:00
Desc: false,
Limit: 5,
Filters: [][]*repository.Filter{
{
repository.NewFilter(repository.FieldAggregateType, repository.AggregateType("user"), repository.OperationEquals),
repository.NewFilter(repository.FieldSequence, uint64(100), repository.OperationGreater),
},
2020-09-24 06:52:10 +00:00
},
},
},
},
{
name: "filter aggregate type, limit, desc, max event sequence cols",
args: args{
columns: ColumnsEvent,
2020-12-01 13:44:19 +00:00
setters: []func(*SearchQueryBuilder) *SearchQueryBuilder{
2020-09-24 06:52:10 +00:00
testSetLimit(5),
testSetSortOrder(false),
2020-10-06 19:28:09 +00:00
testSetColumns(repository.ColumnsMaxSequence),
testAddQuery(
testSetSequence(100),
testSetAggregateTypes("user"),
),
2020-09-24 06:52:10 +00:00
},
},
res: res{
isErr: nil,
2020-09-30 08:00:05 +00:00
query: &repository.SearchQuery{
2020-10-06 19:28:09 +00:00
Columns: repository.ColumnsMaxSequence,
2020-09-24 06:52:10 +00:00
Desc: true,
Limit: 5,
Filters: [][]*repository.Filter{
{
repository.NewFilter(repository.FieldAggregateType, repository.AggregateType("user"), repository.OperationEquals),
repository.NewFilter(repository.FieldSequence, uint64(100), repository.OperationLess),
},
2020-09-24 06:52:10 +00:00
},
},
},
},
{
name: "filter aggregate type and aggregate id",
args: args{
columns: ColumnsEvent,
2020-12-01 13:44:19 +00:00
setters: []func(*SearchQueryBuilder) *SearchQueryBuilder{
testAddQuery(
testSetAggregateTypes("user"),
testSetAggregateIDs("1234"),
),
2020-09-24 06:52:10 +00:00
},
},
res: res{
isErr: nil,
2020-09-30 08:00:05 +00:00
query: &repository.SearchQuery{
2020-10-06 19:28:09 +00:00
Columns: repository.ColumnsEvent,
2020-09-24 06:52:10 +00:00
Desc: false,
Limit: 0,
Filters: [][]*repository.Filter{
{
repository.NewFilter(repository.FieldAggregateType, repository.AggregateType("user"), repository.OperationEquals),
repository.NewFilter(repository.FieldAggregateID, "1234", repository.OperationEquals),
},
},
},
},
},
{
name: "filter multiple aggregate type and aggregate id",
args: args{
columns: ColumnsEvent,
setters: []func(*SearchQueryBuilder) *SearchQueryBuilder{
testAddQuery(
testSetAggregateTypes("user"),
testSetAggregateIDs("1234"),
testOr(
testSetAggregateTypes("org"),
testSetAggregateIDs("izu"),
),
),
},
},
res: res{
isErr: nil,
query: &repository.SearchQuery{
Columns: repository.ColumnsEvent,
Desc: false,
Limit: 0,
Filters: [][]*repository.Filter{
{
repository.NewFilter(repository.FieldAggregateType, repository.AggregateType("user"), repository.OperationEquals),
repository.NewFilter(repository.FieldAggregateID, "1234", repository.OperationEquals),
},
{
repository.NewFilter(repository.FieldAggregateType, repository.AggregateType("org"), repository.OperationEquals),
repository.NewFilter(repository.FieldAggregateID, "izu", repository.OperationEquals),
},
2020-09-24 06:52:10 +00:00
},
},
},
},
{
name: "filter aggregate type and aggregate ids",
args: args{
columns: ColumnsEvent,
2020-12-01 13:44:19 +00:00
setters: []func(*SearchQueryBuilder) *SearchQueryBuilder{
testAddQuery(
testSetAggregateTypes("user"),
testSetAggregateIDs("1234", "0815"),
),
2020-09-24 06:52:10 +00:00
},
},
res: res{
isErr: nil,
2020-09-30 08:00:05 +00:00
query: &repository.SearchQuery{
2020-10-06 19:28:09 +00:00
Columns: repository.ColumnsEvent,
2020-09-24 06:52:10 +00:00
Desc: false,
Limit: 0,
Filters: [][]*repository.Filter{
{
repository.NewFilter(repository.FieldAggregateType, repository.AggregateType("user"), repository.OperationEquals),
repository.NewFilter(repository.FieldAggregateID, []string{"1234", "0815"}, repository.OperationIn),
},
2020-09-24 06:52:10 +00:00
},
},
},
},
{
name: "filter aggregate type and sequence greater",
args: args{
columns: ColumnsEvent,
2020-12-01 13:44:19 +00:00
setters: []func(*SearchQueryBuilder) *SearchQueryBuilder{
testAddQuery(
testSetAggregateTypes("user"),
testSetSequence(8),
),
2020-09-24 06:52:10 +00:00
},
},
res: res{
isErr: nil,
2020-09-30 08:00:05 +00:00
query: &repository.SearchQuery{
2020-10-06 19:28:09 +00:00
Columns: repository.ColumnsEvent,
2020-09-24 06:52:10 +00:00
Desc: false,
Limit: 0,
Filters: [][]*repository.Filter{
{
repository.NewFilter(repository.FieldAggregateType, repository.AggregateType("user"), repository.OperationEquals),
repository.NewFilter(repository.FieldSequence, uint64(8), repository.OperationGreater),
},
2020-09-24 06:52:10 +00:00
},
},
},
},
{
name: "filter aggregate type and event type",
args: args{
columns: ColumnsEvent,
2020-12-01 13:44:19 +00:00
setters: []func(*SearchQueryBuilder) *SearchQueryBuilder{
testAddQuery(
testSetAggregateTypes("user"),
testSetEventTypes("user.created"),
),
2020-09-24 06:52:10 +00:00
},
},
res: res{
isErr: nil,
2020-09-30 08:00:05 +00:00
query: &repository.SearchQuery{
2020-10-06 19:28:09 +00:00
Columns: repository.ColumnsEvent,
2020-09-24 06:52:10 +00:00
Desc: false,
Limit: 0,
Filters: [][]*repository.Filter{
{
repository.NewFilter(repository.FieldAggregateType, repository.AggregateType("user"), repository.OperationEquals),
repository.NewFilter(repository.FieldEventType, repository.EventType("user.created"), repository.OperationEquals),
},
2020-09-24 06:52:10 +00:00
},
},
},
},
{
name: "filter aggregate type and event types",
args: args{
columns: ColumnsEvent,
2020-12-01 13:44:19 +00:00
setters: []func(*SearchQueryBuilder) *SearchQueryBuilder{
testAddQuery(
testSetAggregateTypes("user"),
testSetEventTypes("user.created", "user.changed"),
),
2020-09-24 06:52:10 +00:00
},
},
res: res{
isErr: nil,
2020-09-30 08:00:05 +00:00
query: &repository.SearchQuery{
2020-10-06 19:28:09 +00:00
Columns: repository.ColumnsEvent,
2020-09-24 06:52:10 +00:00
Desc: false,
Limit: 0,
Filters: [][]*repository.Filter{
{
repository.NewFilter(repository.FieldAggregateType, repository.AggregateType("user"), repository.OperationEquals),
repository.NewFilter(repository.FieldEventType, []repository.EventType{"user.created", "user.changed"}, repository.OperationIn),
},
2020-09-24 06:52:10 +00:00
},
},
},
},
{
name: "filter aggregate type resource owner",
args: args{
columns: ColumnsEvent,
2020-12-01 13:44:19 +00:00
setters: []func(*SearchQueryBuilder) *SearchQueryBuilder{
2020-09-24 06:52:10 +00:00
testSetResourceOwner("hodor"),
testAddQuery(
testSetAggregateTypes("user"),
),
2020-09-24 06:52:10 +00:00
},
},
res: res{
isErr: nil,
2020-09-30 08:00:05 +00:00
query: &repository.SearchQuery{
2020-10-06 19:28:09 +00:00
Columns: repository.ColumnsEvent,
2020-09-24 06:52:10 +00:00
Desc: false,
Limit: 0,
Filters: [][]*repository.Filter{
{
repository.NewFilter(repository.FieldAggregateType, repository.AggregateType("user"), repository.OperationEquals),
repository.NewFilter(repository.FieldResourceOwner, "hodor", repository.OperationEquals),
},
2020-09-24 06:52:10 +00:00
},
},
},
},
2020-10-21 17:00:41 +00:00
{
name: "column invalid",
args: args{
columns: Columns(-1),
setters: []func(*SearchQueryBuilder) *SearchQueryBuilder{
testAddQuery(
testSetAggregateTypes("user"),
),
},
2020-10-21 17:00:41 +00:00
},
res: res{
isErr: errors.IsPreconditionFailed,
},
},
2020-09-24 06:52:10 +00:00
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
factory := NewSearchQueryBuilder(tt.args.columns)
2020-09-24 06:52:10 +00:00
for _, f := range tt.args.setters {
factory = f(factory)
}
2020-10-06 19:28:09 +00:00
query, err := factory.build()
2020-09-24 06:52:10 +00:00
if tt.res.isErr != nil && !tt.res.isErr(err) {
2020-10-21 17:00:41 +00:00
t.Errorf("wrong error(%T): %v", err, err)
2020-09-24 06:52:10 +00:00
return
}
if err != nil && tt.res.isErr == nil {
t.Errorf("no error expected: %v", err)
return
}
assertRepoQuery(t, tt.res.query, query)
2020-09-24 06:52:10 +00:00
})
}
}
func assertBuilder(t *testing.T, want, got *SearchQueryBuilder) {
t.Helper()
if got.columns != want.columns {
t.Errorf("wrong column: got: %v want: %v", got.columns, want.columns)
}
if got.desc != want.desc {
t.Errorf("wrong desc: got: %v want: %v", got.desc, want.desc)
}
if got.limit != want.limit {
t.Errorf("wrong limit: got: %v want: %v", got.limit, want.limit)
}
if got.resourceOwner != want.resourceOwner {
t.Errorf("wrong : got: %v want: %v", got.resourceOwner, want.resourceOwner)
}
if len(got.queries) != len(want.queries) {
t.Errorf("wrong length of queries: got: %v want: %v", len(got.queries), len(want.queries))
}
for i, query := range got.queries {
assertQuery(t, i, want.queries[i], query)
}
}
func assertQuery(t *testing.T, i int, want, got *SearchQuery) {
t.Helper()
if !reflect.DeepEqual(got.aggregateIDs, want.aggregateIDs) {
t.Errorf("wrong aggregateIDs in query %d : got: %v want: %v", i, got.aggregateIDs, want.aggregateIDs)
}
if !reflect.DeepEqual(got.aggregateTypes, want.aggregateTypes) {
t.Errorf("wrong aggregateTypes in query %d : got: %v want: %v", i, got.aggregateTypes, want.aggregateTypes)
}
if !reflect.DeepEqual(got.eventData, want.eventData) {
t.Errorf("wrong eventData in query %d : got: %v want: %v", i, got.eventData, want.eventData)
}
if got.eventSequence != want.eventSequence {
t.Errorf("wrong eventSequence in query %d : got: %v want: %v", i, got.eventSequence, want.eventSequence)
}
if !reflect.DeepEqual(got.eventTypes, want.eventTypes) {
t.Errorf("wrong eventTypes in query %d : got: %v want: %v", i, got.eventTypes, want.eventTypes)
}
}
func assertRepoQuery(t *testing.T, want, got *repository.SearchQuery) {
t.Helper()
if want == nil && got == nil {
return
}
if !reflect.DeepEqual(got.Columns, want.Columns) {
t.Errorf("wrong columns in query: got: %v want: %v", got.Columns, want.Columns)
}
if !reflect.DeepEqual(got.Desc, want.Desc) {
t.Errorf("wrong desc in query: got: %v want: %v", got.Desc, want.Desc)
}
if !reflect.DeepEqual(got.Limit, want.Limit) {
t.Errorf("wrong limit in query: got: %v want: %v", got.Limit, want.Limit)
}
if len(got.Filters) != len(want.Filters) {
t.Errorf("wrong length of filters: got: %v want: %v", len(got.Filters), len(want.Filters))
}
for filterIdx, filter := range got.Filters {
if len(got.Filters) != len(want.Filters) {
t.Errorf("wrong length of subfilters: got: %v want: %v", len(filter), len(want.Filters[filterIdx]))
}
for subFilterIdx, f := range filter {
assertFilters(t, subFilterIdx, want.Filters[filterIdx][subFilterIdx], f)
}
}
}
func assertFilters(t *testing.T, i int, want, got *repository.Filter) {
t.Helper()
if want.Field != got.Field {
t.Errorf("wrong field in filter %d : got: %v want: %v", i, got.Field, want.Field)
}
if want.Operation != got.Operation {
t.Errorf("wrong operation in filter %d : got: %v want: %v", i, got.Operation, want.Operation)
}
if !reflect.DeepEqual(want.Value, got.Value) {
t.Errorf("wrong value in filter %d : got: %v want: %v", i, got.Value, want.Value)
}
}