Skip to content

Commit

Permalink
Improve the UUID appender test case
Browse files Browse the repository at this point in the history
  • Loading branch information
asabil committed Oct 29, 2024
1 parent 540775c commit 51d2712
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions appender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,9 @@ func TestAppenderUUID(t *testing.T) {
c, con, a := prepareAppender(t, `CREATE TABLE test (id UUID)`)

id := UUID(uuid.New())
otherId := UUID(uuid.New())
require.NoError(t, a.AppendRow(id))
require.NoError(t, a.AppendRow(otherId))
require.NoError(t, a.AppendRow((*UUID)(nil)))
require.NoError(t, a.AppendRow(nil))
require.NoError(t, a.Flush())
Expand All @@ -464,12 +466,18 @@ func TestAppenderUUID(t *testing.T) {

i := 0
for res.Next() {
var r *UUID
require.NoError(t, res.Scan(&r))
if i == 0 {
require.Equal(t, id, *r)
var r UUID
require.NoError(t, res.Scan(&r))
require.Equal(t, id, r)
} else {
require.Nil(t, r)
var r *UUID
require.NoError(t, res.Scan(&r))
if i == 1 {
require.Equal(t, otherId, *r)
} else {
require.Nil(t, r)
}
}
i++
}
Expand Down

0 comments on commit 51d2712

Please sign in to comment.