diff --git a/internal/test_txn_tx_failure.go b/internal/test_txn_tx_failure.go index b965a9c5..541b4955 100644 --- a/internal/test_txn_tx_failure.go +++ b/internal/test_txn_tx_failure.go @@ -1,11 +1,14 @@ package internal import ( + "fmt" + "github.com/codecrafters-io/redis-tester/internal/redis_executable" resp_value "github.com/codecrafters-io/redis-tester/internal/resp/value" "github.com/codecrafters-io/redis-tester/internal/resp_assertions" "github.com/codecrafters-io/redis-tester/internal/test_cases" + "github.com/codecrafters-io/tester-utils/random" "github.com/codecrafters-io/tester-utils/test_case_harness" ) @@ -25,10 +28,14 @@ func testTxErr(stageHarness *test_case_harness.TestCaseHarness) error { defer client.Close() } + key1, key2 := random.RandomWord(), random.RandomWord() + randomStringValue := random.RandomWord() + randomIntegerValue := random.RandomInt(1, 100) + multiCommandTestCase := test_cases.MultiCommandTestCase{ Commands: [][]string{ - {"SET", "foo", "abc"}, - {"SET", "bar", "7"}, + {"SET", key1, randomStringValue}, + {"SET", key2, fmt.Sprint(randomIntegerValue)}, }, Assertions: []resp_assertions.RESPAssertion{ resp_assertions.NewStringAssertion("OK"), @@ -42,11 +49,11 @@ func testTxErr(stageHarness *test_case_harness.TestCaseHarness) error { transactionTestCase := test_cases.TransactionTestCase{ CommandQueue: [][]string{ - {"INCR", "foo"}, - {"INCR", "bar"}, + {"INCR", key1}, + {"INCR", key2}, }, ResultArray: []resp_value.Value{ - resp_value.NewErrorValue("ERR value is not an integer or out of range"), resp_value.NewIntegerValue(8)}, + resp_value.NewErrorValue("ERR value is not an integer or out of range"), resp_value.NewIntegerValue(randomIntegerValue + 1)}, } if err := transactionTestCase.RunAll(clients[0], logger); err != nil { @@ -55,12 +62,12 @@ func testTxErr(stageHarness *test_case_harness.TestCaseHarness) error { multiCommandTestCase = test_cases.MultiCommandTestCase{ Commands: [][]string{ - {"GET", "bar"}, - {"GET", "foo"}, + {"GET", key2}, + {"GET", key1}, }, Assertions: []resp_assertions.RESPAssertion{ - resp_assertions.NewStringAssertion("8"), - resp_assertions.NewStringAssertion("abc"), + resp_assertions.NewStringAssertion(fmt.Sprint(randomIntegerValue + 1)), + resp_assertions.NewStringAssertion(randomStringValue), }, }