From ba3bda6ac25403fac902e5f5cdfd7faf3db2637a Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Tue, 31 Jul 2018 14:16:17 -0500 Subject: [PATCH] Use string prefix instead of equality so json error message will pass on all Go versions --- http/handler_internal_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/http/handler_internal_test.go b/http/handler_internal_test.go index 0d00d99c3..b0852a79d 100644 --- a/http/handler_internal_test.go +++ b/http/handler_internal_test.go @@ -18,6 +18,7 @@ import ( "bytes" "encoding/json" "reflect" + "strings" "testing" "github.com/pilosa/pilosa" @@ -68,7 +69,7 @@ func TestPostFieldRequestUnmarshalJSON(t *testing.T) { err string }{ {json: `{"options": {}}`, expected: postFieldRequest{}}, - {json: `{"options": 4}`, err: "json: cannot unmarshal number into Go struct field postFieldRequest.options of type http.fieldOptions"}, + {json: `{"options": 4}`, err: "json: cannot unmarshal number"}, {json: `{"option": {}}`, err: `json: unknown field "option"`}, {json: `{"options": {"badKey": "test"}}`, err: `json: unknown field "badKey"`}, {json: `{"options": {"inverseEnabled": true}}`, err: `json: unknown field "inverseEnabled"`}, @@ -81,7 +82,7 @@ func TestPostFieldRequestUnmarshalJSON(t *testing.T) { dec.DisallowUnknownFields() err := dec.Decode(actual) if err != nil { - if test.err == "" || test.err != err.Error() { + if test.err == "" || !strings.HasPrefix(err.Error(), test.err) { t.Errorf("test %d: expected error: %v, but got result: %v", i, test.err, err) } }