ソースを参照

Test unmarshal nil for port

tags/v2.0.0-rc1
9seconds 5年前
コミット
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,

読み込み中…
キャンセル
保存