mirror of https://github.com/tidwall/tile38.git
Removed elapsed member for json testing
This commit is contained in:
parent
e8801fd45a
commit
b86d2287f4
|
@ -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")
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
Loading…
Reference in New Issue