-
Notifications
You must be signed in to change notification settings - Fork 33
/
client_test.go
31 lines (25 loc) · 696 Bytes
/
client_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package radius
import (
"reflect"
"testing"
)
func TestClientList(t *testing.T) {
herd := []Client{
NewClient("1.1.1.1", "secret1"),
NewClient("2.2.2.2", "secret2"),
}
cls := NewClientList(herd)
ok(reflect.DeepEqual(cls.GetHerd(), herd))
newClient := NewClient("3.3.3.3", "secret3")
cls.AddOrUpdate(newClient)
ok(reflect.DeepEqual(cls.Get("3.3.3.3"), newClient))
ok(len(cls.GetHerd()) == 3)
updateClient := NewClient("1.1.1.1", "updatesecret")
cls.AddOrUpdate(updateClient)
ok(reflect.DeepEqual(cls.Get("1.1.1.1"), updateClient))
ok(len(cls.GetHerd()) == 3)
cls.Remove("3.3.3.3")
println(cls.Get("3.3.3.3"))
ok(cls.Get("3.3.3.3") == nil)
ok(len(cls.GetHerd()) == 2)
}