From fb66acebc3d41512a0f9b260a970b9b4fce0a022 Mon Sep 17 00:00:00 2001 From: Dan Sosedoff Date: Thu, 14 Jan 2016 16:55:05 -0600 Subject: [PATCH] Use anonymous structs in the test --- pkg/client/result_test.go | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/pkg/client/result_test.go b/pkg/client/result_test.go index 570f333..56b5d2d 100644 --- a/pkg/client/result_test.go +++ b/pkg/client/result_test.go @@ -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) }