Merge pull request #457 from tidwall/disable-elapsed-tests

Removed elapsed member for json testing
This commit is contained in:
Josh Baker 2019-05-28 09:33:30 -07:00 committed by GitHub
commit 8154eae040
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -15,7 +15,15 @@ func subTestClient(t *testing.T, mc *mockServer) {
} }
func client_valid_json_test(mc *mockServer) error { 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 return err
} }
res, err := mc.Do("CLIENT", "list") res, err := mc.Do("CLIENT", "list")

View File

@ -12,6 +12,7 @@ import (
"time" "time"
"github.com/gomodule/redigo/redis" "github.com/gomodule/redigo/redis"
"github.com/tidwall/sjson"
"github.com/tidwall/tile38/core" "github.com/tidwall/tile38/core"
tlog "github.com/tidwall/tile38/internal/log" tlog "github.com/tidwall/tile38/internal/log"
"github.com/tidwall/tile38/internal/server" "github.com/tidwall/tile38/internal/server"
@ -195,6 +196,12 @@ func (mc *mockServer) DoExpect(expect interface{}, commandName string, args ...i
} }
return err 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 oresp := resp
resp = normalize(resp) resp = normalize(resp)
if expect == nil && resp != nil { if expect == nil && resp != nil {