Add unmarshal nil for type url

This commit is contained in:
9seconds
2021-04-01 21:33:14 +03:00
parent 988f61718c
commit 1fd0ebea9b
+10
View File
@@ -18,6 +18,15 @@ type TypeURLTestSuite struct {
suite.Suite suite.Suite
} }
func (suite *TypeURLTestSuite) TestUnmarshalNil() {
u, _ := url.Parse("https://google.com")
typ := &config.TypeURL{}
suite.NoError(typ.UnmarshalText(nil))
suite.Empty(typ.String())
suite.Equal("https://google.com", typ.Value(u).String())
}
func (suite *TypeURLTestSuite) TestUnmarshalFail() { func (suite *TypeURLTestSuite) TestUnmarshalFail() {
testData := []string{ testData := []string{
"http:/aaa.com", "http:/aaa.com",
@@ -26,6 +35,7 @@ func (suite *TypeURLTestSuite) TestUnmarshalFail() {
"://111", "://111",
"http://aaa.com:xxx", "http://aaa.com:xxx",
"gopher://aaa.com:888", "gopher://aaa.com:888",
"gopher://aaa.com",
} }
for _, v := range testData { for _, v := range testData {