Skip to content

Commit

Permalink
Fix panic in tests
Browse files Browse the repository at this point in the history
--- FAIL: TestSugarInsertAndSelectRows (0.00s)
panic: runtime error: index out of range [0] with length 0 [recovered]
	panic: runtime error: index out of range [0] with length 0
  • Loading branch information
VojtechVitek committed Jun 3, 2024
1 parent 047ce9a commit b9052d9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/pgkit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ func TestSugarInsertAndSelectRows(t *testing.T) {
// Insert
q1 := DB.SQL.Insert("accounts").Columns("name", "disabled").Values("peter", false)
_, err := DB.Query.Exec(context.Background(), q1)
assert.NoError(t, err)
require.NoError(t, err)

// Select
var accounts []*Account
q2 := DB.SQL.Select("*").From("accounts")
err = DB.Query.GetAll(context.Background(), q2, &accounts)

assert.NoError(t, err)
assert.Len(t, accounts, 1)
require.NoError(t, err)
require.Len(t, accounts, 1)
assert.True(t, accounts[0].ID != 0)
assert.Equal(t, "peter", accounts[0].Name)
}
Expand Down

0 comments on commit b9052d9

Please sign in to comment.