-
Notifications
You must be signed in to change notification settings - Fork 190
/
service_test.go
61 lines (51 loc) · 1.28 KB
/
service_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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package service
import (
"encoding/json"
"testing"
)
func TestMinimalService(t *testing.T) {
s := New(TypeOutlet)
if buf, err := json.Marshal(s); err != nil {
t.Fatal(err)
} else {
if is, want := string(buf), "{\"iid\":0,\"type\":\"47\",\"characteristics\":[]}"; is != want {
t.Fatalf("%v != %v", is, want)
}
}
}
func TestPrimaryService(t *testing.T) {
s := New(TypeOutlet)
s.Primary = true
if buf, err := json.Marshal(s); err != nil {
t.Fatal(err)
} else {
if is, want := string(buf), "{\"iid\":0,\"type\":\"47\",\"characteristics\":[],\"primary\":true}"; is != want {
t.Fatalf("%v != %v", is, want)
}
}
}
func TestHiddenService(t *testing.T) {
s := New(TypeOutlet)
s.Hidden = true
if buf, err := json.Marshal(s); err != nil {
t.Fatal(err)
} else {
if is, want := string(buf), "{\"iid\":0,\"type\":\"47\",\"characteristics\":[],\"hidden\":true}"; is != want {
t.Fatalf("%v != %v", is, want)
}
}
}
func TestLinkedService(t *testing.T) {
s := New(TypeOutlet)
s.ID = 1
fan := New(TypeFan)
fan.ID = 2
s.AddLinkedService(fan)
if buf, err := json.Marshal(s); err != nil {
t.Fatal(err)
} else {
if is, want := string(buf), "{\"iid\":1,\"type\":\"47\",\"characteristics\":[],\"linked\":[2]}"; is != want {
t.Fatalf("%v != %v", is, want)
}
}
}