Skip to content

Commit

Permalink
feat: Add testTxExec function
Browse files Browse the repository at this point in the history
This commit adds the `testTxExec` function to the internal package. The function sets up a Redis executable, creates an instrumented RESP connection, and runs a test case for the `EXEC` command.
  • Loading branch information
ryan-gang committed Jun 13, 2024
1 parent 2c4393a commit 2003c23
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions internal/test_txn_exec.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package internal

import (
"github.com/codecrafters-io/redis-tester/internal/redis_executable"
"github.com/codecrafters-io/redis-tester/internal/resp_assertions"

"github.com/codecrafters-io/redis-tester/internal/instrumented_resp_connection"
"github.com/codecrafters-io/redis-tester/internal/test_cases"
"github.com/codecrafters-io/tester-utils/test_case_harness"
)

func testTxExec(stageHarness *test_case_harness.TestCaseHarness) error {
b := redis_executable.NewRedisExecutable(stageHarness)
if err := b.Run(); err != nil {
return err
}

logger := stageHarness.Logger

client, err := instrumented_resp_connection.NewFromAddr(stageHarness, "localhost:6379", "client")
if err != nil {
logFriendlyError(logger, err)
return err
}
defer client.Close()

bareExecCommandTestCase := test_cases.SendCommandTestCase{
Command: "EXEC",
Args: []string{},
Assertion: resp_assertions.NewErrorAssertion("ERR EXEC without MULTI"),
}

return bareExecCommandTestCase.Run(client, logger)
}

0 comments on commit 2003c23

Please sign in to comment.