mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
Add JSON parsing to translator test to verify keys
This commit is contained in:
parent
2739ce436c
commit
e79cd4b199
1 changed files with 19 additions and 0 deletions
|
|
@ -681,6 +681,25 @@ func TestClusterTranslator(t *testing.T) {
|
|||
if result0 != result1 {
|
||||
t.Fatalf("`%s` != `%s`", result0, result1)
|
||||
}
|
||||
|
||||
for _, i := range []string{result0, result1} {
|
||||
var resp map[string]interface{}
|
||||
err := json.Unmarshal([]byte(i), &resp)
|
||||
if err != nil {
|
||||
t.Fatalf("json unmarshal error: %s", err)
|
||||
}
|
||||
if results, ok := resp["results"].([]interface{}); ok {
|
||||
if result, ok := results[0].(map[string]interface{}); ok {
|
||||
if keys, ok := result["keys"].([]interface{}); ok {
|
||||
if key, ok := keys[0].(string); ok {
|
||||
if key != "foo" {
|
||||
t.Fatalf("Key is %s but should be 'foo'", key)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func mustJSONDecode(t *testing.T, r io.Reader) (ret map[string]interface{}) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue