Skip to content

Commit

Permalink
Improved pgx test
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Aug 5, 2024
1 parent a93ce8a commit 28f7b6e
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions pgx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,23 @@ func TestPgx(t *testing.T) {
}

var item PgxItem
row := conn.QueryRow(ctx, "SELECT embedding, sparse_embedding FROM pgx_items ORDER BY id LIMIT 1", pgx.QueryResultFormats{pgx.TextFormatCode, pgx.TextFormatCode})
err = row.Scan(&item.Embedding, &item.SparseEmbedding)
row := conn.QueryRow(ctx, "SELECT embedding, half_embedding, binary_embedding, sparse_embedding FROM pgx_items ORDER BY id DESC LIMIT 1", pgx.QueryResultFormats{pgx.TextFormatCode, pgx.TextFormatCode, pgx.TextFormatCode, pgx.TextFormatCode})
err = row.Scan(&item.Embedding, &item.HalfEmbedding, &item.BinaryEmbedding, &item.SparseEmbedding)
if err != nil {
panic(err)
}
if !reflect.DeepEqual(item.Embedding.Slice(), []float32{1, 1, 2}) {
t.Error()
}
if !reflect.DeepEqual(item.HalfEmbedding.Slice(), []float32{1, 1, 2}) {
t.Error()
}
if item.BinaryEmbedding != "111" {
t.Error()
}
if !reflect.DeepEqual(item.SparseEmbedding.Slice(), []float32{1, 1, 2}) {
t.Error()
}

_, err = conn.CopyFrom(
ctx,
Expand Down

0 comments on commit 28f7b6e

Please sign in to comment.