mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 13:34:02 +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
|
||||
}
|
||||
|
||||
intValue, err := strconv.ParseUint(string(data), 10, 16)
|
||||
intValue, err := strconv.ParseUint(string(data), 10, 64)
|
||||
if err != nil {
|
||||
return fmt.Errorf("port number is not a number: %w", err)
|
||||
}
|
||||
|
||||
@@ -18,6 +18,12 @@ type TypePortTestSuite struct {
|
||||
suite.Suite
|
||||
}
|
||||
|
||||
func (suite *TypePortTestSuite) TestUnmarshalNil() {
|
||||
typ := &config.TypePort{}
|
||||
suite.NoError(typ.UnmarshalJSON(nil))
|
||||
suite.Equal("0", typ.String())
|
||||
}
|
||||
|
||||
func (suite *TypePortTestSuite) TestUnmarshalFail() {
|
||||
testData := []int{
|
||||
-1,
|
||||
|
||||
Reference in New Issue
Block a user