Parcourir la source

Test unmarshal nil for port

tags/v2.0.0-rc1
9seconds il y a 5 ans
Parent
révision
6c92ec314d
2 fichiers modifiés avec 7 ajouts et 1 suppressions
  1. 1
    1
      config/type_port.go
  2. 6
    0
      config/type_port_test.go

+ 1
- 1
config/type_port.go Voir le fichier

@@ -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 Voir le fichier

@@ -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,

Chargement…
Annuler
Enregistrer