Files
go-unifi/unifi/account_test.go
2025-03-19 19:05:56 +01:00

38 lines
726 B
Go

package unifi_test
import (
"encoding/json"
"testing"
"github.com/tj/assert"
"github.com/vegardengen/go-unifi/unifi"
)
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))
})
}
}