Skip to content

Commit

Permalink
feat: Add testTxMulti function to internal package
Browse files Browse the repository at this point in the history
This commit adds the testTxMulti function to the internal package. The function sets up a Redis executable and creates an instrumented RESP connection. It then runs a command test case using the MULTI command with no arguments, asserting that the response is "OK".
  • Loading branch information
ryan-gang committed Jun 13, 2024
1 parent fecf766 commit fb6e805
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions internal/test_txn_multi.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 testTxMulti(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()

commandTestCase := test_cases.SendCommandTestCase{
Command: "MULTI",
Args: []string{},
Assertion: resp_assertions.NewStringAssertion("OK"),
}

return commandTestCase.Run(client, logger)
}

0 comments on commit fb6e805

Please sign in to comment.