From 20310d81bf9bd6cc476a474b8d34704f74844934 Mon Sep 17 00:00:00 2001 From: davidnewhall2 Date: Mon, 22 Jun 2020 01:39:19 -0700 Subject: [PATCH] add small test --- core/unifi/events_test.go | 20 ++++++++++++++++++++ core/unifi/types_test.go | 13 +++++++------ 2 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 core/unifi/events_test.go diff --git a/core/unifi/events_test.go b/core/unifi/events_test.go new file mode 100644 index 00000000..ea3f337a --- /dev/null +++ b/core/unifi/events_test.go @@ -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) +} diff --git a/core/unifi/types_test.go b/core/unifi/types_test.go index 118662e1..bbf13a13 100644 --- a/core/unifi/types_test.go +++ b/core/unifi/types_test.go @@ -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.