From f144d5c1c1e5254a81d3020c363df7cb42f48696 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B0=D0=B2=D0=B5=D0=BB?= Date: Wed, 8 Apr 2020 14:06:15 +0300 Subject: [PATCH] go1.14 fixes --- v1/types_test.go | 6 +----- v1/types_test_1.13.go | 16 ++++++++++++++++ v1/types_test_1.14.go | 16 ++++++++++++++++ 3 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 v1/types_test_1.13.go create mode 100644 v1/types_test_1.14.go diff --git a/v1/types_test.go b/v1/types_test.go index 6f233af..c69cfbf 100644 --- a/v1/types_test.go +++ b/v1/types_test.go @@ -97,9 +97,5 @@ func TestOriginator(t *testing.T) { assert.Equal(t, err, ErrInvalidOriginator) }) - t.Run("MarshalJSON_Invalid", func(t *testing.T) { - data, err := json.Marshal(Originator(3)) - assert.Nil(t, data) - assert.EqualError(t, err, "json: error calling MarshalJSON for type v1.Originator: invalid originator") - }) + t.Run("MarshalJSON_Invalid", OriginatorMarshalJSONInvalid) } diff --git a/v1/types_test_1.13.go b/v1/types_test_1.13.go new file mode 100644 index 0000000..014f825 --- /dev/null +++ b/v1/types_test_1.13.go @@ -0,0 +1,16 @@ +// +build !go1.14 + +package v1 + +import ( + "encoding/json" + "testing" + + "github.com/stretchr/testify/assert" +) + +func OriginatorMarshalJSONInvalid(t *testing.T) { + data, err := json.Marshal(Originator(3)) + assert.Nil(t, data) + assert.EqualError(t, err, "json: error calling MarshalJSON for type v1.Originator: invalid originator") +} diff --git a/v1/types_test_1.14.go b/v1/types_test_1.14.go new file mode 100644 index 0000000..f2c31b6 --- /dev/null +++ b/v1/types_test_1.14.go @@ -0,0 +1,16 @@ +// +build go1.14 + +package v1 + +import ( + "encoding/json" + "testing" + + "github.com/stretchr/testify/assert" +) + +func OriginatorMarshalJSONInvalid(t *testing.T) { + data, err := json.Marshal(Originator(3)) + assert.Nil(t, data) + assert.EqualError(t, err, "json: error calling MarshalText for type v1.Originator: invalid originator") +}