Skip to content

Commit

Permalink
test: fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-bisonai committed Jul 11, 2024
1 parent 311f84e commit 1f2d12f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions node/pkg/dal/tests/stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ func TestInsertRestCall(t *testing.T) {
ctx := context.Background()
_ = db.QueryWithoutResult(ctx, "DELETE FROM rest_calls", nil)

err := stats.InsertRestCall(ctx, "test", "test", 200, 10*time.Millisecond)
err := stats.InsertRestCall(ctx, "testApiKey", "test", 200, 10*time.Millisecond)
assert.NoError(t, err)

result, err := db.QueryRows[RestCall](ctx, "SELECT * FROM rest_calls", nil)
assert.NoError(t, err)
assert.Greater(t, len(result), 0)

assert.Equal(t, "test", result[0].ApiKey)
assert.Equal(t, "testApiKey", result[0].ApiKey)
err = db.QueryWithoutResult(ctx, "DELETE FROM rest_calls", nil)
assert.NoError(t, err)
}
Expand All @@ -56,22 +56,23 @@ func TestInsertWebsocketConnection(t *testing.T) {
ctx := context.Background()
_ = db.QueryWithoutResult(ctx, "DELETE FROM websocket_connections", nil)

id, err := stats.InsertWebsocketConnection(ctx, "test")
id, err := stats.InsertWebsocketConnection(ctx, "testApiKey")
assert.NoError(t, err)
assert.Greater(t, id, int32(0))

result, err := db.QueryRows[WebsocketConnection](ctx, "SELECT * FROM websocket_connections", nil)
assert.NoError(t, err)
assert.Greater(t, len(result), 0)
assert.Equal(t, "test", result[0].ApiKey)

assert.Equal(t, "testApiKey", result[0].ApiKey)
err = db.QueryWithoutResult(ctx, "DELETE FROM websocket_connections", nil)
assert.NoError(t, err)
}

func TestUpdateWebsocketConnection(t *testing.T) {
ctx := context.Background()
_ = db.QueryWithoutResult(ctx, "DELETE FROM websocket_connections", nil)
id, err := stats.InsertWebsocketConnection(ctx, "test")
id, err := stats.InsertWebsocketConnection(ctx, "testApiKey")
assert.NoError(t, err)
assert.Greater(t, id, int32(0))

Expand All @@ -81,7 +82,7 @@ func TestUpdateWebsocketConnection(t *testing.T) {
result, err := db.QueryRows[WebsocketConnection](ctx, "SELECT * FROM websocket_connections", nil)
assert.NoError(t, err)
assert.Greater(t, len(result), 0)
assert.Equal(t, "test", result[0].ApiKey)
assert.Equal(t, "testApiKey", result[0].ApiKey)
assert.NotEqual(t, 0, result[0].Duration)
err = db.QueryWithoutResult(ctx, "DELETE FROM websocket_connections", nil)
assert.NoError(t, err)
Expand All @@ -91,7 +92,7 @@ func TestWebsocketSubcription(t *testing.T) {
ctx := context.Background()
_ = db.QueryWithoutResult(ctx, "DELETE FROM websocket_subscriptions", nil)
_ = db.QueryWithoutResult(ctx, "DELETE FROM websocket_connections", nil)
id, err := stats.InsertWebsocketConnection(ctx, "test")
id, err := stats.InsertWebsocketConnection(ctx, "testApiKey")
assert.NoError(t, err)
assert.Greater(t, id, int32(0))

Expand Down
2 changes: 1 addition & 1 deletion node/taskfiles/taskfile.local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ tasks:
test-dal:
dotenv: [".env"]
cmds:
- go test -p 1 ./pkg/dal/tests -v
- go test ./pkg/dal/tests -v

check-api:
dotenv: [".env"]
Expand Down

0 comments on commit 1f2d12f

Please sign in to comment.