diff --git a/tests/client_test.go b/tests/client_test.go index 99fd03ce..016b88aa 100644 --- a/tests/client_test.go +++ b/tests/client_test.go @@ -15,7 +15,15 @@ func subTestClient(t *testing.T, mc *mockServer) { } func client_valid_json_test(mc *mockServer) error { - if _, err := mc.Do("OUTPUT", "JSON"); err != nil { + if err := mc.DoBatch([][]interface{}{ + // tests removal of "elapsed" member. + {"OUTPUT", "json"}, {`{"ok":true}`}, + {"OUTPUT", "resp"}, {`OK`}, + }); err != nil { + return err + } + // run direct commands + if _, err := mc.Do("OUTPUT", "json"); err != nil { return err } res, err := mc.Do("CLIENT", "list") diff --git a/tests/mock_test.go b/tests/mock_test.go index f4f5f2d6..77825e87 100644 --- a/tests/mock_test.go +++ b/tests/mock_test.go @@ -12,6 +12,7 @@ import ( "time" "github.com/gomodule/redigo/redis" + "github.com/tidwall/sjson" "github.com/tidwall/tile38/core" tlog "github.com/tidwall/tile38/internal/log" "github.com/tidwall/tile38/internal/server" @@ -195,6 +196,12 @@ func (mc *mockServer) DoExpect(expect interface{}, commandName string, args ...i } return err } + if b, ok := resp.([]byte); ok && len(b) > 1 && b[0] == '{' { + b, err = sjson.DeleteBytes(b, "elapsed") + if err == nil { + resp = b + } + } oresp := resp resp = normalize(resp) if expect == nil && resp != nil {