Use anonymous structs in the test
This commit is contained in:
parent
508e49e986
commit
fb66acebc3
@ -52,16 +52,22 @@ func Test_JSON(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
output := result.JSON()
|
obj := []struct {
|
||||||
obj := []map[string]interface{}{}
|
Id int
|
||||||
err := json.Unmarshal(output, &obj)
|
Name string
|
||||||
|
Email string
|
||||||
|
}{}
|
||||||
|
|
||||||
assert.NoError(t, err)
|
expected := []struct {
|
||||||
assert.Equal(t, 2, len(obj))
|
Id int
|
||||||
|
Name string
|
||||||
for i, row := range obj {
|
Email string
|
||||||
for j, col := range result.Columns {
|
}{
|
||||||
assert.Equal(t, result.Rows[i][j], row[col])
|
{1, "John", "john@example.com"},
|
||||||
}
|
{2, "Bob", "bob@example.com"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert.NoError(t, json.Unmarshal(result.JSON(), &obj))
|
||||||
|
assert.Equal(t, 2, len(obj))
|
||||||
|
assert.Equal(t, expected, obj)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user