Просмотр исходного кода

Test unmarshal nil for port

tags/v2.0.0-rc1
9seconds 5 лет назад
Родитель
Сommit
6c92ec314d
2 измененных файлов: 7 добавлений и 1 удалений
  1. 1
    1
      config/type_port.go
  2. 6
    0
      config/type_port_test.go

+ 1
- 1
config/type_port.go Просмотреть файл

@@ -14,7 +14,7 @@ func (c *TypePort) UnmarshalJSON(data []byte) error {
14 14
 		return nil
15 15
 	}
16 16
 
17
-	intValue, err := strconv.ParseUint(string(data), 10, 16)
17
+	intValue, err := strconv.ParseUint(string(data), 10, 64)
18 18
 	if err != nil {
19 19
 		return fmt.Errorf("port number is not a number: %w", err)
20 20
 	}

+ 6
- 0
config/type_port_test.go Просмотреть файл

@@ -18,6 +18,12 @@ type TypePortTestSuite struct {
18 18
 	suite.Suite
19 19
 }
20 20
 
21
+func (suite *TypePortTestSuite) TestUnmarshalNil() {
22
+	typ := &config.TypePort{}
23
+	suite.NoError(typ.UnmarshalJSON(nil))
24
+	suite.Equal("0", typ.String())
25
+}
26
+
21 27
 func (suite *TypePortTestSuite) TestUnmarshalFail() {
22 28
 	testData := []int{
23 29
 		-1,

Загрузка…
Отмена
Сохранить