Skip to content

Commit

Permalink
Merge pull request #162 from codecrafters-io/streams-ext-params-quoting
Browse files Browse the repository at this point in the history
Update parameter quoting in Streams extension
  • Loading branch information
ryan-gang authored Aug 22, 2024
2 parents 84d26d8 + 016c294 commit 6654c27
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 100 deletions.
82 changes: 41 additions & 41 deletions internal/test_helpers/fixtures/streams/pass
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ Debug = true

[stage-44] Running tests for Stage #44: xu1
[stage-44] $ ./spawn_redis_server.sh
[stage-44] $ redis-cli xadd "pear" "0-1" "temperature 70"
[stage-44] Received response: ""0-1""
[stage-44] $ redis-cli xadd pear 0-1 temperature 70
[stage-44] Received response: "0-1"
[stage-44] $ redis-cli xread block 0 streams pear 0-1
[stage-44] $ redis-cli xadd "pear" "0-2" "temperature 70"
[stage-44] Received response: ""0-2""
[stage-44] $ redis-cli xadd pear 0-2 temperature 70
[stage-44] Received response: "0-2"
[stage-44] Received response: "[
[stage-44]  {
[stage-44]  "Stream": "pear",
Expand All @@ -26,11 +26,11 @@ Debug = true

[stage-43] Running tests for Stage #43: hw1
[stage-43] $ ./spawn_redis_server.sh
[stage-43] $ redis-cli xadd "raspberry" "0-1" "temperature 74"
[stage-43] Received response: ""0-1""
[stage-43] $ redis-cli xadd raspberry 0-1 temperature 74
[stage-43] Received response: "0-1"
[stage-43] $ redis-cli xread block 0 streams raspberry 0-1
[stage-43] $ redis-cli xadd "raspberry" "0-2" "temperature 74"
[stage-43] Received response: ""0-2""
[stage-43] $ redis-cli xadd raspberry 0-2 temperature 74
[stage-43] Received response: "0-2"
[stage-43] Received response: "[
[stage-43]  {
[stage-43]  "Stream": "raspberry",
Expand All @@ -50,11 +50,11 @@ Debug = true

[stage-42] Running tests for Stage #42: bs1
[stage-42] $ ./spawn_redis_server.sh
[stage-42] $ redis-cli xadd "pear" "0-1" "temperature 30"
[stage-42] Received response: ""0-1""
[stage-42] $ redis-cli xadd pear 0-1 temperature 30
[stage-42] Received response: "0-1"
[stage-42] $ redis-cli xread block 1000 streams pear 0-1
[stage-42] $ redis-cli xadd "pear" "0-2" "temperature 30"
[stage-42] Received response: ""0-2""
[stage-42] $ redis-cli xadd pear 0-2 temperature 30
[stage-42] Received response: "0-2"
[stage-42] Received response: "[
[stage-42]  {
[stage-42]  "Stream": "pear",
Expand All @@ -76,11 +76,11 @@ Debug = true

[stage-41] Running tests for Stage #41: ru9
[stage-41] $ ./spawn_redis_server.sh
[stage-41] $ redis-cli xadd "blueberry" "0-1" "temperature 24"
[stage-41] Received response: ""0-1""
[stage-41] $ redis-cli xadd "banana" "0-2" "humidity 61"
[stage-41] Received response: ""0-2""
[stage-41] $ redis-cli xread streams "blueberry banana 0-0 0-1"
[stage-41] $ redis-cli xadd blueberry 0-1 temperature 24
[stage-41] Received response: "0-1"
[stage-41] $ redis-cli xadd banana 0-2 humidity 61
[stage-41] Received response: "0-2"
[stage-41] $ redis-cli xread streams blueberry banana 0-0 0-1
[stage-41] Received response: "[
[stage-41]  {
[stage-41]  "Stream": "blueberry",
Expand Down Expand Up @@ -111,9 +111,9 @@ Debug = true

[stage-40] Running tests for Stage #40: um0
[stage-40] $ ./spawn_redis_server.sh
[stage-40] $ redis-cli xadd "grape" "0-1" "temperature 54"
[stage-40] Received response: ""0-1""
[stage-40] $ redis-cli xread streams "grape 0-0"
[stage-40] $ redis-cli xadd grape 0-1 temperature 54
[stage-40] Received response: "0-1"
[stage-40] $ redis-cli xread streams grape 0-0
[stage-40] Received response: "[
[stage-40]  {
[stage-40]  "Stream": "grape",
Expand All @@ -133,13 +133,13 @@ Debug = true

[stage-39] Running tests for Stage #39: fs1
[stage-39] $ ./spawn_redis_server.sh
[stage-39] $ redis-cli xadd "apple" "0-1" "foo bar"
[stage-39] Received response: ""0-1""
[stage-39] $ redis-cli xadd "apple" "0-2" "foo bar"
[stage-39] Received response: ""0-2""
[stage-39] $ redis-cli xadd "apple" "0-3" "foo bar"
[stage-39] Received response: ""0-3""
[stage-39] $ redis-cli xrange "apple" 0-2 +
[stage-39] $ redis-cli xadd apple 0-1 foo bar
[stage-39] Received response: "0-1"
[stage-39] $ redis-cli xadd apple 0-2 foo bar
[stage-39] Received response: "0-2"
[stage-39] $ redis-cli xadd apple 0-3 foo bar
[stage-39] Received response: "0-3"
[stage-39] $ redis-cli xrange apple 0-2 +
[stage-39] Received response: "[
[stage-39]  {
[stage-39]  "ID": "0-2",
Expand All @@ -160,13 +160,13 @@ Debug = true

[stage-38] Running tests for Stage #38: yp1
[stage-38] $ ./spawn_redis_server.sh
[stage-38] $ redis-cli xadd "banana" "0-1" "foo bar"
[stage-38] Received response: ""0-1""
[stage-38] $ redis-cli xadd "banana" "0-2" "foo bar"
[stage-38] Received response: ""0-2""
[stage-38] $ redis-cli xadd "banana" "0-3" "foo bar"
[stage-38] Received response: ""0-3""
[stage-38] $ redis-cli xrange "banana" - "0-2"
[stage-38] $ redis-cli xadd banana 0-1 foo bar
[stage-38] Received response: "0-1"
[stage-38] $ redis-cli xadd banana 0-2 foo bar
[stage-38] Received response: "0-2"
[stage-38] $ redis-cli xadd banana 0-3 foo bar
[stage-38] Received response: "0-3"
[stage-38] $ redis-cli xrange banana - 0-2
[stage-38] Received response: "[
[stage-38]  {
[stage-38]  "ID": "0-1",
Expand All @@ -187,13 +187,13 @@ Debug = true

[stage-37] Running tests for Stage #37: zx1
[stage-37] $ ./spawn_redis_server.sh
[stage-37] $ redis-cli xadd "grape" "0-1" "foo bar"
[stage-37] Received response: ""0-1""
[stage-37] $ redis-cli xadd "grape" "0-2" "foo bar"
[stage-37] Received response: ""0-2""
[stage-37] $ redis-cli xadd "grape" "0-3" "foo bar"
[stage-37] Received response: ""0-3""
[stage-37] $ redis-cli xrange "grape" 0-2 "0-3"
[stage-37] $ redis-cli xadd grape 0-1 foo bar
[stage-37] Received response: "0-1"
[stage-37] $ redis-cli xadd grape 0-2 foo bar
[stage-37] Received response: "0-2"
[stage-37] $ redis-cli xadd grape 0-3 foo bar
[stage-37] Received response: "0-3"
[stage-37] $ redis-cli xrange grape 0-2 0-3
[stage-37] Received response: "[
[stage-37]  {
[stage-37]  "ID": "0-2",
Expand Down
94 changes: 47 additions & 47 deletions internal/test_helpers/fixtures/transactions/pass
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,11 @@ Debug = true

[stage-44] Running tests for Stage #44: xu1
[stage-44] $ ./spawn_redis_server.sh
[stage-44] $ redis-cli xadd "apple" "0-1" "temperature 10"
[stage-44] Received response: ""0-1""
[stage-44] $ redis-cli xadd apple 0-1 temperature 10
[stage-44] Received response: "0-1"
[stage-44] $ redis-cli xread block 0 streams apple 0-1
[stage-44] $ redis-cli xadd "apple" "0-2" "temperature 10"
[stage-44] Received response: ""0-2""
[stage-44] $ redis-cli xadd apple 0-2 temperature 10
[stage-44] Received response: "0-2"
[stage-44] Received response: "[
[stage-44]  {
[stage-44]  "Stream": "apple",
Expand All @@ -393,11 +393,11 @@ Debug = true

[stage-43] Running tests for Stage #43: hw1
[stage-43] $ ./spawn_redis_server.sh
[stage-43] $ redis-cli xadd "banana" "0-1" "temperature 91"
[stage-43] Received response: ""0-1""
[stage-43] $ redis-cli xadd banana 0-1 temperature 91
[stage-43] Received response: "0-1"
[stage-43] $ redis-cli xread block 0 streams banana 0-1
[stage-43] $ redis-cli xadd "banana" "0-2" "temperature 91"
[stage-43] Received response: ""0-2""
[stage-43] $ redis-cli xadd banana 0-2 temperature 91
[stage-43] Received response: "0-2"
[stage-43] Received response: "[
[stage-43]  {
[stage-43]  "Stream": "banana",
Expand All @@ -417,11 +417,11 @@ Debug = true

[stage-42] Running tests for Stage #42: bs1
[stage-42] $ ./spawn_redis_server.sh
[stage-42] $ redis-cli xadd "orange" "0-1" "temperature 2"
[stage-42] Received response: ""0-1""
[stage-42] $ redis-cli xadd orange 0-1 temperature 2
[stage-42] Received response: "0-1"
[stage-42] $ redis-cli xread block 1000 streams orange 0-1
[stage-42] $ redis-cli xadd "orange" "0-2" "temperature 2"
[stage-42] Received response: ""0-2""
[stage-42] $ redis-cli xadd orange 0-2 temperature 2
[stage-42] Received response: "0-2"
[stage-42] Received response: "[
[stage-42]  {
[stage-42]  "Stream": "orange",
Expand All @@ -443,11 +443,11 @@ Debug = true

[stage-41] Running tests for Stage #41: ru9
[stage-41] $ ./spawn_redis_server.sh
[stage-41] $ redis-cli xadd "pineapple" "0-1" "temperature 99"
[stage-41] Received response: ""0-1""
[stage-41] $ redis-cli xadd "orange" "0-2" "humidity 37"
[stage-41] Received response: ""0-2""
[stage-41] $ redis-cli xread streams "pineapple orange 0-0 0-1"
[stage-41] $ redis-cli xadd pineapple 0-1 temperature 99
[stage-41] Received response: "0-1"
[stage-41] $ redis-cli xadd orange 0-2 humidity 37
[stage-41] Received response: "0-2"
[stage-41] $ redis-cli xread streams pineapple orange 0-0 0-1
[stage-41] Received response: "[
[stage-41]  {
[stage-41]  "Stream": "pineapple",
Expand Down Expand Up @@ -478,9 +478,9 @@ Debug = true

[stage-40] Running tests for Stage #40: um0
[stage-40] $ ./spawn_redis_server.sh
[stage-40] $ redis-cli xadd "apple" "0-1" "temperature 88"
[stage-40] Received response: ""0-1""
[stage-40] $ redis-cli xread streams "apple 0-0"
[stage-40] $ redis-cli xadd apple 0-1 temperature 88
[stage-40] Received response: "0-1"
[stage-40] $ redis-cli xread streams apple 0-0
[stage-40] Received response: "[
[stage-40]  {
[stage-40]  "Stream": "apple",
Expand All @@ -500,15 +500,15 @@ Debug = true

[stage-39] Running tests for Stage #39: fs1
[stage-39] $ ./spawn_redis_server.sh
[stage-39] $ redis-cli xadd "apple" "0-1" "foo bar"
[stage-39] Received response: ""0-1""
[stage-39] $ redis-cli xadd "apple" "0-2" "foo bar"
[stage-39] Received response: ""0-2""
[stage-39] $ redis-cli xadd "apple" "0-3" "foo bar"
[stage-39] Received response: ""0-3""
[stage-39] $ redis-cli xadd "apple" "0-4" "foo bar"
[stage-39] Received response: ""0-4""
[stage-39] $ redis-cli xrange "apple" 0-2 +
[stage-39] $ redis-cli xadd apple 0-1 foo bar
[stage-39] Received response: "0-1"
[stage-39] $ redis-cli xadd apple 0-2 foo bar
[stage-39] Received response: "0-2"
[stage-39] $ redis-cli xadd apple 0-3 foo bar
[stage-39] Received response: "0-3"
[stage-39] $ redis-cli xadd apple 0-4 foo bar
[stage-39] Received response: "0-4"
[stage-39] $ redis-cli xrange apple 0-2 +
[stage-39] Received response: "[
[stage-39]  {
[stage-39]  "ID": "0-2",
Expand All @@ -535,15 +535,15 @@ Debug = true

[stage-38] Running tests for Stage #38: yp1
[stage-38] $ ./spawn_redis_server.sh
[stage-38] $ redis-cli xadd "blueberry" "0-1" "foo bar"
[stage-38] Received response: ""0-1""
[stage-38] $ redis-cli xadd "blueberry" "0-2" "foo bar"
[stage-38] Received response: ""0-2""
[stage-38] $ redis-cli xadd "blueberry" "0-3" "foo bar"
[stage-38] Received response: ""0-3""
[stage-38] $ redis-cli xadd "blueberry" "0-4" "foo bar"
[stage-38] Received response: ""0-4""
[stage-38] $ redis-cli xrange "blueberry" - "0-3"
[stage-38] $ redis-cli xadd blueberry 0-1 foo bar
[stage-38] Received response: "0-1"
[stage-38] $ redis-cli xadd blueberry 0-2 foo bar
[stage-38] Received response: "0-2"
[stage-38] $ redis-cli xadd blueberry 0-3 foo bar
[stage-38] Received response: "0-3"
[stage-38] $ redis-cli xadd blueberry 0-4 foo bar
[stage-38] Received response: "0-4"
[stage-38] $ redis-cli xrange blueberry - 0-3
[stage-38] Received response: "[
[stage-38]  {
[stage-38]  "ID": "0-1",
Expand All @@ -570,15 +570,15 @@ Debug = true

[stage-37] Running tests for Stage #37: zx1
[stage-37] $ ./spawn_redis_server.sh
[stage-37] $ redis-cli xadd "grape" "0-1" "foo bar"
[stage-37] Received response: ""0-1""
[stage-37] $ redis-cli xadd "grape" "0-2" "foo bar"
[stage-37] Received response: ""0-2""
[stage-37] $ redis-cli xadd "grape" "0-3" "foo bar"
[stage-37] Received response: ""0-3""
[stage-37] $ redis-cli xadd "grape" "0-4" "foo bar"
[stage-37] Received response: ""0-4""
[stage-37] $ redis-cli xrange "grape" 0-2 "0-4"
[stage-37] $ redis-cli xadd grape 0-1 foo bar
[stage-37] Received response: "0-1"
[stage-37] $ redis-cli xadd grape 0-2 foo bar
[stage-37] Received response: "0-2"
[stage-37] $ redis-cli xadd grape 0-3 foo bar
[stage-37] Received response: "0-3"
[stage-37] $ redis-cli xadd grape 0-4 foo bar
[stage-37] Received response: "0-4"
[stage-37] $ redis-cli xrange grape 0-2 0-4
[stage-37] Received response: "[
[stage-37]  {
[stage-37]  "ID": "0-2",
Expand Down
10 changes: 5 additions & 5 deletions internal/test_streams_xadd.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (t *XADDTest) Run(client *redis.Client, logger *logger.Logger) error {
values = append(values, key, fmt.Sprintf("%v", value))
}

logger.Infof("$ redis-cli xadd %q %q %q", t.streamKey, t.id, strings.Join(values, " "))
logger.Infof("$ redis-cli xadd %v %v %v", t.streamKey, t.id, strings.Join(values, " "))

resp, err := client.XAdd(&redis.XAddArgs{
Stream: t.streamKey,
Expand All @@ -48,18 +48,18 @@ func (t *XADDTest) Run(client *redis.Client, logger *logger.Logger) error {
return fmt.Errorf("Expected %q, got %q", t.expectedError, err.Error())
}

logger.Successf("Received error: \"%q\"", err.Error())
logger.Successf("Received error: %q", err.Error())
return nil
}

if resp != t.expectedResponse && t.expectedError != "" {
logger.Infof("Received response: \"%q\"", resp)
logger.Infof("Received response: %q", resp)
return fmt.Errorf("Expected an error as the response, got %q", resp)
} else if resp != t.expectedResponse {
logger.Infof("Received response: \"%q\"", resp)
logger.Infof("Received response: %q", resp)
return fmt.Errorf("Expected %q, got %q", t.expectedResponse, resp)
} else {
logger.Successf("Received response: \"%q\"", resp)
logger.Successf("Received response: %q", resp)
}

return nil
Expand Down
5 changes: 3 additions & 2 deletions internal/test_streams_xrange.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package internal
import (
"encoding/json"
"fmt"
"github.com/codecrafters-io/redis-tester/internal/redis_executable"
"reflect"
"strconv"

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

testerutils_random "github.com/codecrafters-io/tester-utils/random"
"github.com/codecrafters-io/tester-utils/test_case_harness"
"github.com/go-redis/redis"
Expand Down Expand Up @@ -55,7 +56,7 @@ func testStreamsXrange(stageHarness *test_case_harness.TestCaseHarness) error {
maxID := "0-" + strconv.Itoa(randomNumber)
expectedResp = expectedResp[1:]

logger.Infof("$ redis-cli xrange %q 0-2 %q", randomKey, maxID)
logger.Infof("$ redis-cli xrange %v 0-2 %v", randomKey, maxID)
resp, err := client.XRange(randomKey, "0-2", maxID).Result()

if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions internal/test_streams_xrange_max_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package internal
import (
"encoding/json"
"fmt"
"github.com/codecrafters-io/redis-tester/internal/redis_executable"
"reflect"
"strconv"

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

testerutils_random "github.com/codecrafters-io/tester-utils/random"
"github.com/codecrafters-io/tester-utils/test_case_harness"
"github.com/go-redis/redis"
Expand Down Expand Up @@ -56,7 +57,7 @@ func testStreamsXrangeMaxID(stageHarness *test_case_harness.TestCaseHarness) err
})
}

logger.Infof("$ redis-cli xrange %q 0-2 +", randomKey)
logger.Infof("$ redis-cli xrange %v 0-2 +", randomKey)
resp, err := client.XRange(randomKey, "0-2", "+").Result()

if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions internal/test_streams_xrange_min_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package internal
import (
"encoding/json"
"fmt"
"github.com/codecrafters-io/redis-tester/internal/redis_executable"
"reflect"
"strconv"

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

testerutils_random "github.com/codecrafters-io/tester-utils/random"
"github.com/codecrafters-io/tester-utils/test_case_harness"
"github.com/go-redis/redis"
Expand Down Expand Up @@ -58,7 +59,7 @@ func testStreamsXrangeMinID(stageHarness *test_case_harness.TestCaseHarness) err
})
}

logger.Infof("$ redis-cli xrange %q - %q", randomKey, maxID)
logger.Infof("$ redis-cli xrange %v - %v", randomKey, maxID)
resp, err := client.XRange(randomKey, "-", maxID).Result()

if err != nil {
Expand Down
Loading

0 comments on commit 6654c27

Please sign in to comment.