Pārlūkot izejas kodu

Add unmarshal nil for type url

tags/v2.0.0-rc1
9seconds 5 gadus atpakaļ
vecāks
revīzija
1fd0ebea9b
1 mainītis faili ar 10 papildinājumiem un 0 dzēšanām
  1. 10
    0
      config/type_url_test.go

+ 10
- 0
config/type_url_test.go Parādīt failu

@@ -18,6 +18,15 @@ type TypeURLTestSuite struct {
18 18
 	suite.Suite
19 19
 }
20 20
 
21
+func (suite *TypeURLTestSuite) TestUnmarshalNil() {
22
+	u, _ := url.Parse("https://google.com")
23
+
24
+	typ := &config.TypeURL{}
25
+	suite.NoError(typ.UnmarshalText(nil))
26
+	suite.Empty(typ.String())
27
+	suite.Equal("https://google.com", typ.Value(u).String())
28
+}
29
+
21 30
 func (suite *TypeURLTestSuite) TestUnmarshalFail() {
22 31
 	testData := []string{
23 32
 		"http:/aaa.com",
@@ -26,6 +35,7 @@ func (suite *TypeURLTestSuite) TestUnmarshalFail() {
26 35
 		"://111",
27 36
 		"http://aaa.com:xxx",
28 37
 		"gopher://aaa.com:888",
38
+		"gopher://aaa.com",
29 39
 	}
30 40
 
31 41
 	for _, v := range testData {

Notiek ielāde…
Atcelt
Saglabāt