Преглед на файлове

Add unmarshal nil for typestatsdtagsformat

tags/v2.0.0-rc1
9seconds преди 5 години
родител
ревизия
988f61718c
променени са 1 файла, в които са добавени 12 реда и са изтрити 6 реда
  1. 12
    6
      config/type_statsd_tag_format_test.go

+ 12
- 6
config/type_statsd_tag_format_test.go Целия файл

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

Loading…
Отказ
Запис