Skip to content

Commit

Permalink
refactor: improve transaction test cases
Browse files Browse the repository at this point in the history
- Skip execution of transaction commands
- Use `RunAll` instead of `RunMulti` and `RunQueueAll`
- Update result array for each transaction command
  • Loading branch information
ryan-gang committed Jun 13, 2024
1 parent 28be476 commit a3957c1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
9 changes: 3 additions & 6 deletions internal/test_txn_discard.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,11 @@ func testTxDiscard(stageHarness *test_case_harness.TestCaseHarness) error {
{"SET", "foo", "41"},
{"INCR", "foo"},
},
ResultArray: []resp_value.Value{},
ResultArray: []resp_value.Value{},
ShouldSkipExec: true,
}

if err := transactionTestCase.RunMulti(client, logger); err != nil {
return err
}

if err := transactionTestCase.RunQueueAll(client, logger); err != nil {
if err := transactionTestCase.RunAll(client, logger); err != nil {
return err
}

Expand Down
9 changes: 3 additions & 6 deletions internal/test_txn_multi_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,10 @@ func testTxMultiTx(stageHarness *test_case_harness.TestCaseHarness) error {
{"INCR", "foo"},
{"INCR", "bar"},
},
ResultArray: []resp_value.Value{resp_value.NewIntegerValue(4 + i), resp_value.NewIntegerValue(8 + i)},
}
if err := transactionTestCase.RunMulti(client, logger); err != nil {
return err
ResultArray: []resp_value.Value{resp_value.NewIntegerValue(4 + i), resp_value.NewIntegerValue(8 + i)},
ShouldSkipExec: true,
}

if err := transactionTestCase.RunQueueAll(client, logger); err != nil {
if err := transactionTestCase.RunAll(client, logger); err != nil {
return err
}
}
Expand Down
9 changes: 3 additions & 6 deletions internal/test_txn_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,11 @@ func testTxQueue(stageHarness *test_case_harness.TestCaseHarness) error {
{"SET", "foo", "41"},
{"INCR", "foo"},
},
ResultArray: []resp_value.Value{},
ResultArray: []resp_value.Value{},
ShouldSkipExec: true,
}

if err := transactionTestCase.RunMulti(clients[0], logger); err != nil {
return err
}

if err := transactionTestCase.RunQueueAll(clients[0], logger); err != nil {
if err := transactionTestCase.RunAll(clients[0], logger); err != nil {
return err
}

Expand Down

0 comments on commit a3957c1

Please sign in to comment.