Skip to content

Commit c42e6a6

Browse files
committed
fixup! retry insert active key on tx serialization failure
1 parent 381f078 commit c42e6a6

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

enterprise/dbcrypt/dbcrypt_internal_test.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -494,11 +494,11 @@ func TestNew(t *testing.T) {
494494

495495
gomock.InOrder(
496496
// First try: we get a serialization error.
497-
expectTx(mockDB),
497+
expectInTx(mockDB),
498498
mockDB.EXPECT().GetDBCryptKeys(gomock.Any()).Times(1).Return([]database.DBCryptKey{}, nil),
499499
mockDB.EXPECT().InsertDBCryptKey(gomock.Any(), gomock.Any()).Times(1).Return(&pq.Error{Code: "40001"}),
500500
// Second try: we get the key we wanted to insert initially.
501-
expectTx(mockDB),
501+
expectInTx(mockDB),
502502
mockDB.EXPECT().GetDBCryptKeys(gomock.Any()).Times(1).Return([]database.DBCryptKey{key}, nil),
503503
)
504504

@@ -507,7 +507,7 @@ func TestNew(t *testing.T) {
507507
})
508508
}
509509

510-
func expectTx(mdb *dbmock.MockStore) *gomock.Call {
510+
func expectInTx(mdb *dbmock.MockStore) *gomock.Call {
511511
return mdb.EXPECT().InTx(gomock.Any(), gomock.Any()).Times(1).DoAndReturn(
512512
func(f func(store database.Store) error, _ *sql.TxOptions) error {
513513
return f(mdb)
@@ -554,11 +554,3 @@ func fakeBase64RandomData(t *testing.T, n int) string {
554554
require.NoError(t, err)
555555
return base64.StdEncoding.EncodeToString(b)
556556
}
557-
558-
func withInTx(mTx *dbmock.MockStore) {
559-
mTx.EXPECT().InTx(gomock.Any(), gomock.Any()).Times(1).DoAndReturn(
560-
func(f func(store database.Store) error, _ *sql.TxOptions) error {
561-
return f(mTx)
562-
},
563-
)
564-
}

0 commit comments

Comments
 (0)