Sfoglia il codice sorgente

Test unmarshal nil for port

tags/v2.0.0-rc1
9seconds 5 anni fa
parent
commit
6c92ec314d
2 ha cambiato i file con 7 aggiunte e 1 eliminazioni
  1. 1
    1
      config/type_port.go
  2. 6
    0
      config/type_port_test.go

+ 1
- 1
config/type_port.go Vedi File

14
 		return nil
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
 	if err != nil {
18
 	if err != nil {
19
 		return fmt.Errorf("port number is not a number: %w", err)
19
 		return fmt.Errorf("port number is not a number: %w", err)
20
 	}
20
 	}

+ 6
- 0
config/type_port_test.go Vedi File

18
 	suite.Suite
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
 func (suite *TypePortTestSuite) TestUnmarshalFail() {
27
 func (suite *TypePortTestSuite) TestUnmarshalFail() {
22
 	testData := []int{
28
 	testData := []int{
23
 		-1,
29
 		-1,

Loading…
Annulla
Salva