Files
go-unifi/unifi/account_test.go
Vegard Engen 54bcc0897c
Some checks failed
/ yamllint (push) Failing after 2s
/ build (push) Failing after 23s
/ test (push) Has been skipped
/ lint (push) Failing after 23s
/ generate (push) Has been skipped
Move repo
2025-06-23 18:36:07 +02:00

38 lines
736 B
Go

package unifi_test
import (
"encoding/json"
"testing"
"github.com/tj/assert"
"gitea.engen.priv.no/klauvsteinen/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))
})
}
}