Skip to content

Commit

Permalink
Fix events list tests (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
nt0xa authored Mar 21, 2023
1 parent 39b12e4 commit 8e223d4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
10 changes: 5 additions & 5 deletions internal/actionsdb/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestEventsList_Success(t *testing.T) {
Count: 10,
},
9,
1, 9,
9, 1,
},
{
"count",
Expand All @@ -40,7 +40,7 @@ func TestEventsList_Success(t *testing.T) {
Count: 5,
},
5,
1, 5,
9, 5,
},
{
"after",
Expand All @@ -50,7 +50,7 @@ func TestEventsList_Success(t *testing.T) {
After: 4,
},
5,
5, 9,
9, 5,
},
{
"before",
Expand All @@ -60,7 +60,7 @@ func TestEventsList_Success(t *testing.T) {
Before: 9,
},
5,
4, 8,
8, 4,
},
{
"reverse",
Expand All @@ -71,7 +71,7 @@ func TestEventsList_Success(t *testing.T) {
Reverse: true,
},
5,
8, 4,
4, 8,
},
}

Expand Down
20 changes: 10 additions & 10 deletions internal/database/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ func TestEventsListByPayloadID_Success(t *testing.T) {
l, err := db.EventsListByPayloadID(1)
assert.NoError(t, err)
require.Len(t, l, 9)
assert.EqualValues(t, l[0].ID, 1)
assert.EqualValues(t, l[len(l)-1].ID, 9)
assert.EqualValues(t, l[0].ID, 9)
assert.EqualValues(t, l[len(l)-1].ID, 1)

l, err = db.EventsListByPayloadID(1,
database.EventsPagination(database.Page{
Expand All @@ -80,8 +80,8 @@ func TestEventsListByPayloadID_Success(t *testing.T) {
// Count
assert.NoError(t, err)
require.Len(t, l, 3)
assert.EqualValues(t, l[0].ID, 1)
assert.EqualValues(t, l[len(l)-1].ID, 3)
assert.EqualValues(t, l[0].ID, 9)
assert.EqualValues(t, l[len(l)-1].ID, 7)

// Before
l, err = db.EventsListByPayloadID(1,
Expand All @@ -92,8 +92,8 @@ func TestEventsListByPayloadID_Success(t *testing.T) {
)
assert.NoError(t, err)
require.Len(t, l, 5)
assert.EqualValues(t, l[0].ID, 2)
assert.EqualValues(t, l[len(l)-1].ID, 6)
assert.EqualValues(t, l[0].ID, 6)
assert.EqualValues(t, l[len(l)-1].ID, 2)

// After
l, err = db.EventsListByPayloadID(1,
Expand All @@ -104,8 +104,8 @@ func TestEventsListByPayloadID_Success(t *testing.T) {
)
assert.NoError(t, err)
require.Len(t, l, 2)
assert.EqualValues(t, l[0].ID, 8)
assert.EqualValues(t, l[len(l)-1].ID, 9)
assert.EqualValues(t, l[0].ID, 9)
assert.EqualValues(t, l[len(l)-1].ID, 8)

// Reverse
l, err = db.EventsListByPayloadID(1,
Expand All @@ -117,8 +117,8 @@ func TestEventsListByPayloadID_Success(t *testing.T) {
)
assert.NoError(t, err)
require.Len(t, l, 2)
assert.EqualValues(t, l[0].ID, 9)
assert.EqualValues(t, l[len(l)-1].ID, 8)
assert.EqualValues(t, l[0].ID, 8)
assert.EqualValues(t, l[len(l)-1].ID, 9)
}

func TestEventsGetByPayloadAndIndex_Success(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions internal/modules/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,8 +546,8 @@ func TestAPI(t *testing.T) {
schema: (actions.EventsListResult)(nil),
result: map[string]matcher{
"$": length(9),
"$[0].protocol": equal("dns"),
"$[1].protocol": equal("http"),
"$[0].protocol": equal("http"),
"$[8].protocol": equal("dns"),
},
status: 200,
},
Expand Down
4 changes: 2 additions & 2 deletions internal/modules/api/apiclient/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,8 @@ func TestClient(t *testing.T) {
PayloadName: "payload1",
},
map[string]matcher{
"0.Protocol": equal("dns"),
"1.Protocol": equal("http"),
"0.Protocol": equal("http"),
"8.Protocol": equal("dns"),
},
nil,
},
Expand Down

0 comments on commit 8e223d4

Please sign in to comment.