mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 20:14:01 +03:00
Test unmarshal nil for port
This commit is contained in:
+1
-1
@@ -14,7 +14,7 @@ func (c *TypePort) UnmarshalJSON(data []byte) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
intValue, err := strconv.ParseUint(string(data), 10, 16)
|
intValue, err := strconv.ParseUint(string(data), 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("port number is not a number: %w", err)
|
return fmt.Errorf("port number is not a number: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,12 @@ type TypePortTestSuite struct {
|
|||||||
suite.Suite
|
suite.Suite
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (suite *TypePortTestSuite) TestUnmarshalNil() {
|
||||||
|
typ := &config.TypePort{}
|
||||||
|
suite.NoError(typ.UnmarshalJSON(nil))
|
||||||
|
suite.Equal("0", typ.String())
|
||||||
|
}
|
||||||
|
|
||||||
func (suite *TypePortTestSuite) TestUnmarshalFail() {
|
func (suite *TypePortTestSuite) TestUnmarshalFail() {
|
||||||
testData := []int{
|
testData := []int{
|
||||||
-1,
|
-1,
|
||||||
|
|||||||
Reference in New Issue
Block a user