Skip to content

Commit

Permalink
fixing ornull handler & extracting vars for infinity values
Browse files Browse the repository at this point in the history
Signed-off-by: TJ Zhang <[email protected]>
  • Loading branch information
TJ Zhang committed Jan 22, 2025
1 parent ed42230 commit fc83e0e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 29 deletions.
2 changes: 1 addition & 1 deletion go/api/response_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ func handleMapOfArrayOfStringArrayResponse(response *C.struct_CommandResponse) (
}

func handleMapOfArrayOfStringArrayOrNilResponse(response *C.struct_CommandResponse) (map[string][][]string, error) {
if response == nil || response.response_type == uint32(C.Null) {
if response.response_type == uint32(C.Null) {
return nil, nil
}

Expand Down
58 changes: 30 additions & 28 deletions go/integTest/shared_commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7216,6 +7216,8 @@ func (suite *GlideTestSuite) TestXRangeAndXRevRange() {
key := uuid.New().String()
key2 := uuid.New().String()
stringKey := uuid.New().String()
positiveInfinity := options.NewInfiniteStreamBoundary(options.PositiveInfinity)
negativeInfinity := options.NewInfiniteStreamBoundary(options.NegativeInfinity)

// add stream entries
streamId1, err := client.XAdd(
Expand All @@ -7239,8 +7241,8 @@ func (suite *GlideTestSuite) TestXRangeAndXRevRange() {
// get everything from the stream
xrangeResult, err := client.XRange(
key,
options.NewInfiniteStreamBoundary(options.NegativeInfinity),
options.NewInfiniteStreamBoundary(options.PositiveInfinity),
negativeInfinity,
positiveInfinity,
)
assert.NoError(suite.T(), err)
assert.Equal(
Expand All @@ -7252,8 +7254,8 @@ func (suite *GlideTestSuite) TestXRangeAndXRevRange() {
// get everything from the stream in reverse
xrevrangeResult, err := client.XRevRange(
key,
options.NewInfiniteStreamBoundary(options.PositiveInfinity),
options.NewInfiniteStreamBoundary(options.NegativeInfinity),
positiveInfinity,
negativeInfinity,
)
assert.NoError(suite.T(), err)
assert.Equal(
Expand All @@ -7265,17 +7267,17 @@ func (suite *GlideTestSuite) TestXRangeAndXRevRange() {
// returns empty map if + before -
xrangeResult, err = client.XRange(
key,
options.NewInfiniteStreamBoundary(options.PositiveInfinity),
options.NewInfiniteStreamBoundary(options.NegativeInfinity),
positiveInfinity,
negativeInfinity,
)
assert.NoError(suite.T(), err)
assert.Empty(suite.T(), xrangeResult)

// rev search returns empty if - before +
xrevrangeResult, err = client.XRevRange(
key,
options.NewInfiniteStreamBoundary(options.NegativeInfinity),
options.NewInfiniteStreamBoundary(options.PositiveInfinity),
negativeInfinity,
positiveInfinity,
)
assert.NoError(suite.T(), err)
assert.Empty(suite.T(), xrevrangeResult)
Expand All @@ -7291,7 +7293,7 @@ func (suite *GlideTestSuite) TestXRangeAndXRevRange() {
xrangeResult, err = client.XRangeWithCount(
key,
options.NewStreamBoundary(streamId2.Value(), false),
options.NewInfiniteStreamBoundary(options.PositiveInfinity),
positiveInfinity,
1,
)
assert.NoError(suite.T(), err)
Expand All @@ -7304,7 +7306,7 @@ func (suite *GlideTestSuite) TestXRangeAndXRevRange() {
// doing the same with rev search
xrevrangeResult, err = client.XRevRangeWithCount(
key,
options.NewInfiniteStreamBoundary(options.PositiveInfinity),
positiveInfinity,
options.NewStreamBoundary(streamId2.Value(), false),
1,
)
Expand All @@ -7318,17 +7320,17 @@ func (suite *GlideTestSuite) TestXRangeAndXRevRange() {
// both xrange and xrevrange return nil with a zero/negative count
xrangeResult, err = client.XRangeWithCount(
key,
options.NewInfiniteStreamBoundary(options.NegativeInfinity),
options.NewInfiniteStreamBoundary(options.PositiveInfinity),
negativeInfinity,
positiveInfinity,
0,
)
assert.NoError(suite.T(), err)
assert.Empty(suite.T(), xrangeResult)

xrevrangeResult, err = client.XRevRangeWithCount(
key,
options.NewInfiniteStreamBoundary(options.PositiveInfinity),
options.NewInfiniteStreamBoundary(options.NegativeInfinity),
positiveInfinity,
negativeInfinity,
-1,
)
assert.NoError(suite.T(), err)
Expand All @@ -7341,33 +7343,33 @@ func (suite *GlideTestSuite) TestXRangeAndXRevRange() {

xrangeResult, err = client.XRange(
key,
options.NewInfiniteStreamBoundary(options.NegativeInfinity),
options.NewInfiniteStreamBoundary(options.PositiveInfinity),
negativeInfinity,
positiveInfinity,
)
assert.NoError(suite.T(), err)
assert.Empty(suite.T(), xrangeResult)

xrevrangeResult, err = client.XRevRange(
key,
options.NewInfiniteStreamBoundary(options.PositiveInfinity),
options.NewInfiniteStreamBoundary(options.NegativeInfinity),
positiveInfinity,
negativeInfinity,
)
assert.NoError(suite.T(), err)
assert.Empty(suite.T(), xrevrangeResult)

// xrange and xrevrange against a non-existent stream
xrangeResult, err = client.XRange(
key2,
options.NewInfiniteStreamBoundary(options.NegativeInfinity),
options.NewInfiniteStreamBoundary(options.PositiveInfinity),
negativeInfinity,
positiveInfinity,
)
assert.NoError(suite.T(), err)
assert.Empty(suite.T(), xrangeResult)

xrevrangeResult, err = client.XRevRange(
key2,
options.NewInfiniteStreamBoundary(options.PositiveInfinity),
options.NewInfiniteStreamBoundary(options.NegativeInfinity),
positiveInfinity,
negativeInfinity,
)
assert.NoError(suite.T(), err)
assert.Empty(suite.T(), xrevrangeResult)
Expand All @@ -7377,16 +7379,16 @@ func (suite *GlideTestSuite) TestXRangeAndXRevRange() {
assert.NoError(suite.T(), err)
_, err = client.XRange(
stringKey,
options.NewInfiniteStreamBoundary(options.NegativeInfinity),
options.NewInfiniteStreamBoundary(options.PositiveInfinity),
negativeInfinity,
positiveInfinity,
)
assert.Error(suite.T(), err)
assert.IsType(suite.T(), &api.RequestError{}, err)

_, err = client.XRevRange(
stringKey,
options.NewInfiniteStreamBoundary(options.PositiveInfinity),
options.NewInfiniteStreamBoundary(options.NegativeInfinity),
positiveInfinity,
negativeInfinity,
)
assert.Error(suite.T(), err)
assert.IsType(suite.T(), &api.RequestError{}, err)
Expand All @@ -7395,15 +7397,15 @@ func (suite *GlideTestSuite) TestXRangeAndXRevRange() {
_, err = client.XRange(
key,
options.NewStreamBoundary("invalid-id", false),
options.NewInfiniteStreamBoundary(options.PositiveInfinity),
positiveInfinity,
)
assert.Error(suite.T(), err)
assert.IsType(suite.T(), &api.RequestError{}, err)

_, err = client.XRevRange(
key,
options.NewStreamBoundary("invalid-id", false),
options.NewInfiniteStreamBoundary(options.NegativeInfinity),
negativeInfinity,
)
assert.Error(suite.T(), err)
assert.IsType(suite.T(), &api.RequestError{}, err)
Expand Down

0 comments on commit fc83e0e

Please sign in to comment.