From 988f61718c7a04e7c552e8cd4510250469e714c9 Mon Sep 17 00:00:00 2001 From: 9seconds Date: Thu, 1 Apr 2021 21:29:48 +0300 Subject: [PATCH] Add unmarshal nil for typestatsdtagsformat --- config/type_statsd_tag_format_test.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/config/type_statsd_tag_format_test.go b/config/type_statsd_tag_format_test.go index 2c7074f..e3975af 100644 --- a/config/type_statsd_tag_format_test.go +++ b/config/type_statsd_tag_format_test.go @@ -14,11 +14,17 @@ type typeStatsdTagFormatTestStruct struct { Value config.TypeStatsdTagFormat `json:"value"` } -type TypeStatsdTagFormat struct { +type TypeStatsdTagFormatTestSuite struct { suite.Suite } -func (suite *TypeStatsdTagFormat) TestUnmarshalFail() { +func (suite *TypeStatsdTagFormatTestSuite) TestUnmarshalNil() { + typ := &config.TypeStatsdTagFormat{} + suite.NoError(typ.UnmarshalText(nil)) + suite.Equal("lalala", typ.Value("lalala")) +} + +func (suite *TypeStatsdTagFormatTestSuite) TestUnmarshalFail() { testData := []string{ "p", "ipv4", @@ -38,7 +44,7 @@ func (suite *TypeStatsdTagFormat) TestUnmarshalFail() { } } -func (suite *TypeStatsdTagFormat) TestUnmarshalOk() { +func (suite *TypeStatsdTagFormatTestSuite) TestUnmarshalOk() { testData := []string{ config.TypeStatsdTagFormatDatadog, config.TypeStatsdTagFormatInfluxdb, @@ -70,7 +76,7 @@ func (suite *TypeStatsdTagFormat) TestUnmarshalOk() { } } -func (suite *TypeStatsdTagFormat) TestMarshalOk() { +func (suite *TypeStatsdTagFormatTestSuite) TestMarshalOk() { testData := []string{ config.TypeStatsdTagFormatDatadog, config.TypeStatsdTagFormatInfluxdb, @@ -104,7 +110,7 @@ func (suite *TypeStatsdTagFormat) TestMarshalOk() { } } -func (suite *TypeStatsdTagFormat) TestValue() { +func (suite *TypeStatsdTagFormatTestSuite) TestValue() { testStruct := &typePreferIPTestStruct{} suite.EqualValues(config.TypePreferIPPreferIPv4, @@ -126,5 +132,5 @@ func (suite *TypeStatsdTagFormat) TestValue() { func TestTypeStatsdTagFormat(t *testing.T) { t.Parallel() - suite.Run(t, &TypeStatsdTagFormat{}) + suite.Run(t, &TypeStatsdTagFormatTestSuite{}) }