Browse Source

Add unmarshal nil for typestatsdtagsformat

tags/v2.0.0-rc1
9seconds 5 years ago
parent
commit
988f61718c
1 changed files with 12 additions and 6 deletions
  1. 12
    6
      config/type_statsd_tag_format_test.go

+ 12
- 6
config/type_statsd_tag_format_test.go View File

14
 	Value config.TypeStatsdTagFormat `json:"value"`
14
 	Value config.TypeStatsdTagFormat `json:"value"`
15
 }
15
 }
16
 
16
 
17
-type TypeStatsdTagFormat struct {
17
+type TypeStatsdTagFormatTestSuite struct {
18
 	suite.Suite
18
 	suite.Suite
19
 }
19
 }
20
 
20
 
21
-func (suite *TypeStatsdTagFormat) TestUnmarshalFail() {
21
+func (suite *TypeStatsdTagFormatTestSuite) TestUnmarshalNil() {
22
+	typ := &config.TypeStatsdTagFormat{}
23
+	suite.NoError(typ.UnmarshalText(nil))
24
+	suite.Equal("lalala", typ.Value("lalala"))
25
+}
26
+
27
+func (suite *TypeStatsdTagFormatTestSuite) TestUnmarshalFail() {
22
 	testData := []string{
28
 	testData := []string{
23
 		"p",
29
 		"p",
24
 		"ipv4",
30
 		"ipv4",
38
 	}
44
 	}
39
 }
45
 }
40
 
46
 
41
-func (suite *TypeStatsdTagFormat) TestUnmarshalOk() {
47
+func (suite *TypeStatsdTagFormatTestSuite) TestUnmarshalOk() {
42
 	testData := []string{
48
 	testData := []string{
43
 		config.TypeStatsdTagFormatDatadog,
49
 		config.TypeStatsdTagFormatDatadog,
44
 		config.TypeStatsdTagFormatInfluxdb,
50
 		config.TypeStatsdTagFormatInfluxdb,
70
 	}
76
 	}
71
 }
77
 }
72
 
78
 
73
-func (suite *TypeStatsdTagFormat) TestMarshalOk() {
79
+func (suite *TypeStatsdTagFormatTestSuite) TestMarshalOk() {
74
 	testData := []string{
80
 	testData := []string{
75
 		config.TypeStatsdTagFormatDatadog,
81
 		config.TypeStatsdTagFormatDatadog,
76
 		config.TypeStatsdTagFormatInfluxdb,
82
 		config.TypeStatsdTagFormatInfluxdb,
104
 	}
110
 	}
105
 }
111
 }
106
 
112
 
107
-func (suite *TypeStatsdTagFormat) TestValue() {
113
+func (suite *TypeStatsdTagFormatTestSuite) TestValue() {
108
 	testStruct := &typePreferIPTestStruct{}
114
 	testStruct := &typePreferIPTestStruct{}
109
 
115
 
110
 	suite.EqualValues(config.TypePreferIPPreferIPv4,
116
 	suite.EqualValues(config.TypePreferIPPreferIPv4,
126
 
132
 
127
 func TestTypeStatsdTagFormat(t *testing.T) {
133
 func TestTypeStatsdTagFormat(t *testing.T) {
128
 	t.Parallel()
134
 	t.Parallel()
129
-	suite.Run(t, &TypeStatsdTagFormat{})
135
+	suite.Run(t, &TypeStatsdTagFormatTestSuite{})
130
 }
136
 }

Loading…
Cancel
Save