MCPcopy Index your code
hub / github.com/coder/coder / TestReadModifyUpdate_RetryOK

Function TestReadModifyUpdate_RetryOK

coderd/database/tx_test.go:31–50  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

29}
30
31func TestReadModifyUpdate_RetryOK(t *testing.T) {
32 t.Parallel()
33
34 mDB := dbmock.NewMockStore(gomock.NewController(t))
35
36 firstUpdate := mDB.EXPECT().
37 InTx(gomock.Any(), &database.TxOptions{Isolation: sql.LevelRepeatableRead}).
38 Times(1).
39 Return(&pq.Error{Code: pq.ErrorCode("40001")})
40 mDB.EXPECT().
41 InTx(gomock.Any(), &database.TxOptions{Isolation: sql.LevelRepeatableRead}).
42 After(firstUpdate).
43 Times(1).
44 Return(nil)
45
46 err := database.ReadModifyUpdate(mDB, func(tx database.Store) error {
47 return nil
48 })
49 require.NoError(t, err)
50}
51
52func TestReadModifyUpdate_HardError(t *testing.T) {
53 t.Parallel()

Callers

nothing calls this directly

Calls 4

EXPECTMethod · 0.95
NewMockStoreFunction · 0.92
ReadModifyUpdateFunction · 0.92
InTxMethod · 0.65

Tested by

no test coverage detected