Files
go-unifi/unifi/account_test.go
Oskar 3e7bd072ea Omit empty NetworkID in account resource (#59)
* Omit empty NetworkID in account

* Run `go generate`

* Fix tests

Co-authored-by: Joshua Spence <josh@joshuaspence.com>
2022-01-31 15:58:42 +11:00

38 lines
723 B
Go

package unifi_test
import (
"encoding/json"
"testing"
"github.com/paultyng/go-unifi/unifi"
"github.com/tj/assert"
)
func TestAccountMarshalJSON(t *testing.T) {
for n, c := range map[string]struct {
expectedJSON string
acc unifi.Account
}{
"empty strings": {
`{"vlan":"","tunnel_type":"","tunnel_medium_type":""}`,
unifi.Account{},
},
"response": {
`{"vlan":10,"tunnel_type":1,"tunnel_medium_type":1}`,
unifi.Account{
VLAN: 10,
TunnelType: 1,
TunnelMediumType: 1,
},
},
} {
t.Run(n, func(t *testing.T) {
actual, err := json.Marshal(&c.acc)
if err != nil {
t.Fatal(err)
}
assert.JSONEq(t, c.expectedJSON, string(actual))
})
}
}