@@ -1837,10 +1837,17 @@ func TestIssue229UnexpectedNullWhileParseNilJsonDocumentValue(t *testing.T) {
18371837 ctx , cancel := context .WithCancel (context .Background ())
18381838 defer cancel ()
18391839
1840- db := connect (t )
1841- defer db .Close (ctx )
1840+ db , err := ydb .Open (ctx ,
1841+ os .Getenv ("YDB_CONNECTION_STRING" ),
1842+ ydb .WithAccessTokenCredentials (os .Getenv ("YDB_ACCESS_TOKEN_CREDENTIALS" )),
1843+ )
1844+ require .NoError (t , err )
1845+ defer func (db ydb.Connection ) {
1846+ // cleanup
1847+ _ = db .Close (ctx )
1848+ }(db )
18421849 var val issue229Struct
1843- err : = db .Table ().DoTx (ctx , func (ctx context.Context , tx table.TransactionActor ) error {
1850+ err = db .Table ().DoTx (ctx , func (ctx context.Context , tx table.TransactionActor ) error {
18441851 res , err := tx .Execute (ctx , `SELECT Nothing(JsonDocument?) AS r` , nil )
18451852 if err != nil {
18461853 return err
@@ -1859,22 +1866,16 @@ func TestIssue229UnexpectedNullWhileParseNilJsonDocumentValue(t *testing.T) {
18591866 require .NoError (t , err )
18601867}
18611868
1862- func (scope * tableTestScope ) connect (t testing.TB ) ydb.Connection {
1863- db , err := ydb .Open (
1864- context .Background (),
1865- os .Getenv ("YDB_CONNECTION_STRING" ),
1866- ydb .WithAccessTokenCredentials (os .Getenv ("YDB_ACCESS_TOKEN_CREDENTIALS" )))
1867- require .NoError (t , err )
1868- return db
1869- }
1870-
18711869func TestIssue259IntervalFromDuration (t * testing.T ) {
18721870 // https://github.com/ydb-platform/ydb-go-sdk/issues/259
18731871 ctx , cancel := context .WithCancel (context .Background ())
18741872 defer cancel ()
18751873
1876- db := connect (t )
1877- defer db .Close (ctx )
1874+ db , err := ydb .Open (ctx ,
1875+ os .Getenv ("YDB_CONNECTION_STRING" ),
1876+ ydb .WithAccessTokenCredentials (os .Getenv ("YDB_ACCESS_TOKEN_CREDENTIALS" )),
1877+ )
1878+ require .NoError (t , err )
18781879
18791880 t .Run ("Check about interval work with microseconds" , func (t * testing.T ) {
18801881 err := db .Table ().DoTx (ctx , func (ctx context.Context , tx table.TransactionActor ) error {
@@ -1981,9 +1982,12 @@ func TestIssue415ScanError(t *testing.T) {
19811982 ctx , cancel := context .WithCancel (context .Background ())
19821983 defer cancel ()
19831984
1984- db := connect (t )
1985- defer db .Close (ctx )
1986- err := db .Table ().DoTx (ctx , func (ctx context.Context , tx table.TransactionActor ) error {
1985+ db , err := ydb .Open (ctx ,
1986+ os .Getenv ("YDB_CONNECTION_STRING" ),
1987+ ydb .WithAccessTokenCredentials (os .Getenv ("YDB_ACCESS_TOKEN_CREDENTIALS" )),
1988+ )
1989+ require .NoError (t , err )
1990+ err = db .Table ().DoTx (ctx , func (ctx context.Context , tx table.TransactionActor ) error {
19871991 res , err := tx .Execute (ctx , `SELECT 1 as abc, 2 as def;` , nil )
19881992 if err != nil {
19891993 return err
@@ -2028,9 +2032,12 @@ func TestNullType(t *testing.T) {
20282032 ctx , cancel := context .WithCancel (context .Background ())
20292033 defer cancel ()
20302034
2031- db := connect (t )
2032- defer db .Close (ctx )
2033- err := db .Table ().DoTx (ctx , func (ctx context.Context , tx table.TransactionActor ) error {
2035+ db , err := ydb .Open (ctx ,
2036+ os .Getenv ("YDB_CONNECTION_STRING" ),
2037+ ydb .WithAccessTokenCredentials (os .Getenv ("YDB_ACCESS_TOKEN_CREDENTIALS" )),
2038+ )
2039+ require .NoError (t , err )
2040+ err = db .Table ().DoTx (ctx , func (ctx context.Context , tx table.TransactionActor ) error {
20342041 res , err := tx .Execute (ctx , `SELECT NULL AS reschedule_due;` , nil )
20352042 if err != nil {
20362043 return err
0 commit comments