test: eventstore query

This commit is contained in:
adlerhurst 2020-10-21 09:39:24 +02:00
parent 370597a0e8
commit 83121ab44d

View File

@ -829,7 +829,7 @@ func TestCRDB_query_events(t *testing.T) {
existingEvents []*repository.Event existingEvents []*repository.Event
} }
type res struct { type res struct {
events []*repository.Event eventCount int
} }
tests := []struct { tests := []struct {
name string name string
@ -840,6 +840,76 @@ func TestCRDB_query_events(t *testing.T) {
}{ }{
{ {
name: "aggregate type filter no events", name: "aggregate type filter no events",
args: args{
searchQuery: &repository.SearchQuery{
Columns: repository.ColumnsEvent,
Filters: []*repository.Filter{
repository.NewFilter(repository.FieldAggregateType, "not found", repository.OperationEquals),
},
},
},
fields: fields{
existingEvents: []*repository.Event{
generateEvent(t, "300", false, 0),
generateEvent(t, "300", false, 0),
generateEvent(t, "300", false, 0),
},
},
res: res{
eventCount: 0,
},
wantErr: false,
},
{
name: "aggregate type filter events found",
args: args{
searchQuery: &repository.SearchQuery{
Columns: repository.ColumnsEvent,
Filters: []*repository.Filter{
repository.NewFilter(repository.FieldAggregateType, t.Name(), repository.OperationEquals),
},
},
},
fields: fields{
existingEvents: []*repository.Event{
generateEvent(t, "301", false, 0),
generateEvent(t, "302", false, 0),
generateEvent(t, "302", false, 0),
generateEventForAggregate("not in list", "303", false, 0),
},
},
res: res{
eventCount: 3,
},
wantErr: false,
},
{
name: "aggregate type and id filter events found",
args: args{
searchQuery: &repository.SearchQuery{
Columns: repository.ColumnsEvent,
Filters: []*repository.Filter{
repository.NewFilter(repository.FieldAggregateType, t.Name(), repository.OperationEquals),
repository.NewFilter(repository.FieldAggregateID, "303", repository.OperationEquals),
},
},
},
fields: fields{
existingEvents: []*repository.Event{
generateEvent(t, "303", false, 0),
generateEvent(t, "303", false, 0),
generateEvent(t, "303", false, 0),
generateEventForAggregate("not in list", "304", false, 0),
generateEvent(t, "305", false, 0),
},
},
res: res{
eventCount: 3,
},
wantErr: false,
},
{
name: "sequence filter events found",
args: args{ args: args{
searchQuery: &repository.SearchQuery{}, searchQuery: &repository.SearchQuery{},
}, },
@ -852,45 +922,6 @@ func TestCRDB_query_events(t *testing.T) {
wantErr: false, wantErr: false,
}, },
// { // {
// name: "aggregate type filter events found",
// args: args{
// searchQuery: &repository.SearchQuery{},
// },
// fields: fields{
// existingEvents: []*repository.Event{},
// },
// res: res{
// events: []*repository.Event{},
// },
// wantErr: false,
// },
// {
// name: "aggregate type and id filter events found",
// args: args{
// searchQuery: &repository.SearchQuery{},
// },
// fields: fields{
// existingEvents: []*repository.Event{},
// },
// res: res{
// events: []*repository.Event{},
// },
// wantErr: false,
// },
// {
// name: "sequence filter events found",
// args: args{
// searchQuery: &repository.SearchQuery{},
// },
// fields: fields{
// existingEvents: []*repository.Event{},
// },
// res: res{
// events: []*repository.Event{},
// },
// wantErr: false,
// },
// {
// name: "resource owner filter events found", // name: "resource owner filter events found",
// args: args{ // args: args{
// searchQuery: &repository.SearchQuery{}, // searchQuery: &repository.SearchQuery{},