add small test

This commit is contained in:
davidnewhall2
2020-06-22 01:42:23 -07:00
parent 822f6d23d3
commit 20310d81bf
2 changed files with 27 additions and 6 deletions
+20
View File
@@ -0,0 +1,20 @@
package unifi_test
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/unifi-poller/unifi"
)
func TestIPGeoUnmarshalJSON(t *testing.T) {
t.Parallel()
a := assert.New(t)
i := &unifi.IPGeo{}
a.Nil(i.UnmarshalJSON([]byte(`[]`)))
a.EqualValues(0, i.Asn)
a.Nil(i.UnmarshalJSON([]byte(`{"asn": 123}`)))
a.EqualValues(123, i.Asn)
}
+7 -6
View File
@@ -1,10 +1,11 @@
package unifi // nolint: testpackage
package unifi_test
import (
"encoding/json"
"testing"
"github.com/stretchr/testify/assert"
"github.com/unifi-poller/unifi"
)
func TestFlexInt(t *testing.T) {
@@ -13,11 +14,11 @@ func TestFlexInt(t *testing.T) {
five, seven := 5, 7
var r struct {
Five FlexInt `json:"five"`
Seven FlexInt `json:"seven"`
Auto FlexInt `json:"auto"`
Channel FlexInt `json:"channel"`
Nil FlexInt `json:"nil"`
Five unifi.FlexInt `json:"five"`
Seven unifi.FlexInt `json:"seven"`
Auto unifi.FlexInt `json:"auto"`
Channel unifi.FlexInt `json:"channel"`
Nil unifi.FlexInt `json:"nil"`
}
// test unmarshalling the custom type three times with different values.