Expose the Account API (RADIUS users)
* Adds Account CRUD API * Enahnces `emptyStringInt` with a predicate for dynamically setting which value should be interpreted as a blank JSON payload
This commit is contained in:
committed by
Paul Tyng
parent
ae40573bb7
commit
47fa522aba
37
unifi/account_test.go
Normal file
37
unifi/account_test.go
Normal file
@@ -0,0 +1,37 @@
|
||||
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))
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user