Skip to content

Commit

Permalink
fixed integration tests with database/sql driver over query service
Browse files Browse the repository at this point in the history
  • Loading branch information
asmyasnikov committed Dec 11, 2024
1 parent 5bd342d commit 33ae952
Showing 1 changed file with 32 additions and 15 deletions.
47 changes: 32 additions & 15 deletions tests/integration/database_sql_regression_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

"github.com/ydb-platform/ydb-go-sdk/v3"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql/conn/table/badconn"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xtest"
"github.com/ydb-platform/ydb-go-sdk/v3/retry"
Expand Down Expand Up @@ -234,7 +235,12 @@ func TestUUIDSerializationDatabaseSQLIssue1501(t *testing.T) {
var res [16]byte

err := row.Scan(&res)
require.Error(t, err)
switch driverEngine(db) {
case xsql.TABLE_SERVICE:
require.Error(t, err)
case xsql.QUERY_SERVICE:
require.NoError(t, err)
}
})
t.Run("old-receive-to-bytes-with-force-wrapper", func(t *testing.T) {
// test old behavior - for test way of safe work with data, written with bagged API version
Expand All @@ -256,10 +262,14 @@ func TestUUIDSerializationDatabaseSQLIssue1501(t *testing.T) {
var res types.UUIDBytesWithIssue1501Type

err := row.Scan(&res)
require.NoError(t, err)

resUUID := uuid.UUID(res.AsBytesArray())
require.Equal(t, expectedResultWithBug, resUUID.String())
switch driverEngine(db) {
case xsql.TABLE_SERVICE:
require.NoError(t, err)
resUUID := uuid.UUID(res.AsBytesArray())
require.Equal(t, expectedResultWithBug, resUUID.String())
case xsql.QUERY_SERVICE:
require.Error(t, err)
}
})

t.Run("old-receive-to-string", func(t *testing.T) {
Expand Down Expand Up @@ -341,11 +351,14 @@ func TestUUIDSerializationDatabaseSQLIssue1501(t *testing.T) {

var resBytes types.UUIDBytesWithIssue1501Type
err := row.Scan(&resBytes)
require.NoError(t, err)

resUUID := uuid.UUID(resBytes.AsBytesArray())

require.Equal(t, id, resUUID)
switch driverEngine(db) {
case xsql.TABLE_SERVICE:
require.NoError(t, err)
resUUID := uuid.UUID(resBytes.AsBytesArray())
require.Equal(t, id, resUUID)
case xsql.QUERY_SERVICE:
require.Error(t, err)
}
})
t.Run("old-send-uuid-receive-error-bad-request", func(t *testing.T) {
var (
Expand Down Expand Up @@ -405,12 +418,16 @@ func TestUUIDSerializationDatabaseSQLIssue1501(t *testing.T) {
var resFromDB types.UUIDBytesWithIssue1501Type

err := row.Scan(&resFromDB)
require.NoError(t, err)

resUUID := resFromDB.PublicRevertReorderForIssue1501()
switch driverEngine(db) {
case xsql.TABLE_SERVICE:
require.NoError(t, err)
resUUID := resFromDB.PublicRevertReorderForIssue1501()
resString := strings.ToUpper(resUUID.String())
require.Equal(t, idString, resString)
case xsql.QUERY_SERVICE:
require.Error(t, err)
}

resString := strings.ToUpper(resUUID.String())
require.Equal(t, idString, resString)
})
t.Run("good-send-receive", func(t *testing.T) {
var (
Expand Down

0 comments on commit 33ae952

Please sign in to comment.