Skip to content

Commit 066faa8

Browse files
committed
feat: introduce SendCommandWithSyncTestCase for enhanced command execution in tests
- Added SendCommandWithSyncTestCase struct to facilitate command execution with synchronization and retry logic. - Updated testStreamsXreadBlockMaxID to utilize the new SendCommandWithSyncTestCase for improved handling of XREAD commands.
1 parent c8df7d0 commit 066faa8

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

internal/test_cases/await_command_test_case.go renamed to internal/test_cases/send_command_with_sync_test_case.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/codecrafters-io/tester-utils/logger"
1212
)
1313

14-
type AwaitCommandTestCase struct {
14+
type SendCommandWithSyncTestCase struct {
1515
Command string
1616
Args []string
1717
Assertion resp_assertions.RESPAssertion
@@ -26,7 +26,7 @@ type AwaitCommandTestCase struct {
2626
DoneChan chan bool
2727
}
2828

29-
func (t *AwaitCommandTestCase) Run(client *resp_client.RespConnection, logger *logger.Logger) error {
29+
func (t *SendCommandWithSyncTestCase) Run(client *resp_client.RespConnection, logger *logger.Logger) error {
3030
var value resp_value.Value
3131
var err error
3232

@@ -41,6 +41,8 @@ func (t *AwaitCommandTestCase) Run(client *resp_client.RespConnection, logger *l
4141
return err
4242
}
4343

44+
<-t.AwaitChan
45+
4446
value, err = client.ReadValue()
4547
if err != nil {
4648
return err
@@ -64,8 +66,6 @@ func (t *AwaitCommandTestCase) Run(client *resp_client.RespConnection, logger *l
6466

6567
t.ReceivedResponse = value
6668

67-
<-t.AwaitChan
68-
6969
if err = t.Assertion.Run(value); err != nil {
7070
return err
7171
}

internal/test_streams_xread_block_max_id.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func testStreamsXreadBlockMaxID(stageHarness *test_case_harness.TestCaseHarness)
5454
FieldValuePairs: [][]string{{"temperature", strconv.Itoa(randomInt)}},
5555
}},
5656
}})
57-
awaitXReadTestCase := &test_cases.AwaitCommandTestCase{
57+
xReadWithSyncTestCase := &test_cases.SendCommandWithSyncTestCase{
5858
Command: "XREAD",
5959
Args: []string{"block", "0", "streams", randomKey, "$"},
6060
Assertion: assertion,
@@ -63,7 +63,7 @@ func testStreamsXreadBlockMaxID(stageHarness *test_case_harness.TestCaseHarness)
6363
DoneChan: xReadDone,
6464
}
6565

66-
return awaitXReadTestCase.Run(client1, logger)
66+
return xReadWithSyncTestCase.Run(client1, logger)
6767
}()
6868

6969
time.Sleep(1000 * time.Millisecond)

0 commit comments

Comments
 (0)