mirror of
https://github.com/sosedoff/pgweb.git
synced 2024-12-14 19:21:46 +03:00
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 := []map[string]interface{}{}
|
||||
err := json.Unmarshal(output, &obj)
|
||||
obj := []struct {
|
||||
Id int
|
||||
Name string
|
||||
Email string
|
||||
}{}
|
||||
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 2, len(obj))
|
||||
|
||||
for i, row := range obj {
|
||||
for j, col := range result.Columns {
|
||||
assert.Equal(t, result.Rows[i][j], row[col])
|
||||
}
|
||||
expected := []struct {
|
||||
Id int
|
||||
Name string
|
||||
Email string
|
||||
}{
|
||||
{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…
Reference in New Issue
Block a user