Skip to content

Commit ff642ea

Browse files
committed
refactor: introduce NewXReadResponseAssertion constructor for improved response assertion in testStreamsXreadBlockMaxID
1 parent 9576977 commit ff642ea

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

internal/resp_assertions/xread_response_assertion.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ type XReadResponseAssertion struct {
2222
ExpectedStreamResponses []StreamResponse
2323
}
2424

25+
func NewXReadResponseAssertion(expectedValue []StreamResponse) RESPAssertion {
26+
return XReadResponseAssertion{ExpectedStreamResponses: expectedValue}
27+
}
28+
2529
func (a XReadResponseAssertion) Run(value resp_value.Value) error {
2630
if value.Type != resp_value.ARRAY {
2731
return fmt.Errorf("Expected array, got %s", value.Type)

internal/test_streams_xread_block_max_id.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,13 @@ func testStreamsXreadBlockMaxID(stageHarness *test_case_harness.TestCaseHarness)
4646
randomInt = testerutils_random.RandomInt(1, 100)
4747

4848
go func() error {
49-
assertion := resp_assertions.XReadResponseAssertion{
50-
ExpectedStreamResponses: []resp_assertions.StreamResponse{{
51-
Key: randomKey,
52-
Entries: []resp_assertions.StreamEntry{{
53-
Id: "0-2",
54-
FieldValuePairs: [][]string{{"temperature", strconv.Itoa(randomInt)}},
55-
}},
49+
assertion := resp_assertions.NewXReadResponseAssertion([]resp_assertions.StreamResponse{{
50+
Key: randomKey,
51+
Entries: []resp_assertions.StreamEntry{{
52+
Id: "0-2",
53+
FieldValuePairs: [][]string{{"temperature", strconv.Itoa(randomInt)}},
5654
}},
57-
}
55+
}})
5856
xreadCommandTestCase := &test_cases.SendCommandTestCase{
5957
Command: "XREAD",
6058
Args: []string{"block", "0", "streams", randomKey, "$"},

0 commit comments

Comments
 (0)