@@ -452,11 +452,8 @@ describe('Spanner with mock server', () => {
452452 request . requestOptions ! . transactionTag ,
453453 'transaction-tag'
454454 ) ;
455- const beginTxnRequest = spannerMock . getRequests ( ) . find ( val => {
456- return ( val as v1 . BeginTransactionRequest ) . options ?. readWrite ;
457- } ) as v1 . BeginTransactionRequest ;
458455 assert . strictEqual (
459- beginTxnRequest . options ?. readWrite ! . readLockMode ,
456+ request . transaction ?. begin ?. readWrite ? .readLockMode ,
460457 'OPTIMISTIC'
461458 ) ;
462459 } ) ;
@@ -3758,120 +3755,6 @@ describe('Spanner with mock server', () => {
37583755 ) ;
37593756 } ) ;
37603757
3761- it ( 'should use beginTransaction on retry for unknown reason' , async ( ) => {
3762- const database = newTestDatabase ( ) ;
3763- await database . runTransactionAsync ( async tx => {
3764- try {
3765- await tx . runUpdate ( invalidSql ) ;
3766- assert . fail ( 'missing expected error' ) ;
3767- } catch ( e ) {
3768- assert . strictEqual (
3769- ( e as ServiceError ) . message ,
3770- `${ grpc . status . NOT_FOUND } NOT_FOUND: ${ fooNotFoundErr . message } `
3771- ) ;
3772- }
3773- await tx . run ( selectSql ) ;
3774- await tx . commit ( ) ;
3775- } ) ;
3776- await database . close ( ) ;
3777-
3778- const beginTxnRequest = spannerMock
3779- . getRequests ( )
3780- . filter ( val => ( val as v1 . BeginTransactionRequest ) . options ?. readWrite )
3781- . map ( req => req as v1 . BeginTransactionRequest ) ;
3782- assert . deepStrictEqual ( beginTxnRequest . length , 1 ) ;
3783- } ) ;
3784-
3785- it ( 'should use beginTransaction on retry for unknown reason with excludeTxnFromChangeStreams' , async ( ) => {
3786- const database = newTestDatabase ( ) ;
3787- await database . runTransactionAsync (
3788- {
3789- excludeTxnFromChangeStreams : true ,
3790- } ,
3791- async tx => {
3792- try {
3793- await tx . runUpdate ( invalidSql ) ;
3794- assert . fail ( 'missing expected error' ) ;
3795- } catch ( e ) {
3796- assert . strictEqual (
3797- ( e as ServiceError ) . message ,
3798- `${ grpc . status . NOT_FOUND } NOT_FOUND: ${ fooNotFoundErr . message } `
3799- ) ;
3800- }
3801- await tx . run ( selectSql ) ;
3802- await tx . commit ( ) ;
3803- }
3804- ) ;
3805- await database . close ( ) ;
3806-
3807- const beginTxnRequest = spannerMock
3808- . getRequests ( )
3809- . filter ( val => ( val as v1 . BeginTransactionRequest ) . options ?. readWrite )
3810- . map ( req => req as v1 . BeginTransactionRequest ) ;
3811- assert . deepStrictEqual ( beginTxnRequest . length , 1 ) ;
3812- assert . strictEqual (
3813- beginTxnRequest [ 0 ] . options ?. excludeTxnFromChangeStreams ,
3814- true
3815- ) ;
3816- } ) ;
3817-
3818- it ( 'should use beginTransaction for streaming on retry for unknown reason' , async ( ) => {
3819- const database = newTestDatabase ( ) ;
3820- await database . runTransactionAsync ( async tx => {
3821- try {
3822- await getRowCountFromStreamingSql ( tx ! , { sql : invalidSql } ) ;
3823- assert . fail ( 'missing expected error' ) ;
3824- } catch ( e ) {
3825- assert . strictEqual (
3826- ( e as ServiceError ) . message ,
3827- `${ grpc . status . NOT_FOUND } NOT_FOUND: ${ fooNotFoundErr . message } `
3828- ) ;
3829- }
3830- await tx . run ( selectSql ) ;
3831- await tx . commit ( ) ;
3832- } ) ;
3833- await database . close ( ) ;
3834-
3835- const beginTxnRequest = spannerMock
3836- . getRequests ( )
3837- . filter ( val => ( val as v1 . BeginTransactionRequest ) . options ?. readWrite )
3838- . map ( req => req as v1 . BeginTransactionRequest ) ;
3839- assert . deepStrictEqual ( beginTxnRequest . length , 1 ) ;
3840- } ) ;
3841-
3842- it ( 'should use beginTransaction for streaming on retry for unknown reason with excludeTxnFromChangeStreams' , async ( ) => {
3843- const database = newTestDatabase ( ) ;
3844- await database . runTransactionAsync (
3845- {
3846- excludeTxnFromChangeStreams : true ,
3847- } ,
3848- async tx => {
3849- try {
3850- await getRowCountFromStreamingSql ( tx ! , { sql : invalidSql } ) ;
3851- assert . fail ( 'missing expected error' ) ;
3852- } catch ( e ) {
3853- assert . strictEqual (
3854- ( e as ServiceError ) . message ,
3855- `${ grpc . status . NOT_FOUND } NOT_FOUND: ${ fooNotFoundErr . message } `
3856- ) ;
3857- }
3858- await tx . run ( selectSql ) ;
3859- await tx . commit ( ) ;
3860- }
3861- ) ;
3862- await database . close ( ) ;
3863-
3864- const beginTxnRequest = spannerMock
3865- . getRequests ( )
3866- . filter ( val => ( val as v1 . BeginTransactionRequest ) . options ?. readWrite )
3867- . map ( req => req as v1 . BeginTransactionRequest ) ;
3868- assert . deepStrictEqual ( beginTxnRequest . length , 1 ) ;
3869- assert . strictEqual (
3870- beginTxnRequest [ 0 ] . options ?. excludeTxnFromChangeStreams ,
3871- true
3872- ) ;
3873- } ) ;
3874-
38753758 it ( 'should fail if beginTransaction fails' , async ( ) => {
38763759 const database = newTestDatabase ( ) ;
38773760 const err = {
0 commit comments