forked from amimof/huego
-
Notifications
You must be signed in to change notification settings - Fork 0
/
resourcelink_test.go
88 lines (80 loc) · 2.08 KB
/
resourcelink_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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package huego_test
import (
"github.com/amimof/huego"
"testing"
)
func TestGetResourcelinks(t *testing.T) {
b := huego.New(hostname, username)
resourcelinks, err := b.GetResourcelinks()
if err != nil {
t.Fatal(err)
}
t.Logf("Found %d resourcelinks", len(resourcelinks))
for i, resourcelink := range resourcelinks {
t.Logf("%d", i)
t.Logf(" Name: %s", resourcelink.Name)
t.Logf(" Description: %s", resourcelink.Description)
t.Logf(" Type: %s", resourcelink.Type)
t.Logf(" ClassID: %d", resourcelink.ClassID)
t.Logf(" Owner: %s", resourcelink.Owner)
t.Logf(" Links: %s", resourcelink.Links)
t.Logf(" ID: %d", resourcelink.ID)
}
}
func TestGetResourcelink(t *testing.T) {
b := huego.New(hostname, username)
l, err := b.GetResourcelink(1)
if err != nil {
t.Fatal(err)
}
t.Logf("Name: %s", l.Name)
t.Logf("Description: %s", l.Description)
t.Logf("Type: %s", l.Type)
t.Logf("ClassID: %d", l.ClassID)
t.Logf("Owner: %s", l.Owner)
t.Logf("Links: %s", l.Links)
t.Logf("ID: %d", l.ID)
}
func TestCreateResourcelink(t *testing.T) {
b := huego.New(hostname, username)
resourcelink := &huego.Resourcelink{
Name: "Huego Test Resourcelink",
Description: "Amir's wakeup experience",
Type: "Link",
ClassID: 1,
Owner: "78H56B12BAABCDEF",
Links: []string{"/schedules/2", "/schedules/3", "/scenes/ABCD"},
}
resp, err := b.CreateResourcelink(resourcelink)
if err != nil {
t.Fatal(err)
}
t.Logf("Resourcelink created")
for k, v := range resp.Success {
t.Logf("%v: %s", k, v)
}
}
func TestUpdateResourcelink(t *testing.T) {
b := huego.New(hostname, username)
id := 1
resp, err := b.UpdateResourcelink(id, &huego.Resourcelink{
Name: "New Resourcelink",
Description: "Updated Attribute",
})
if err != nil {
t.Fatal(err)
}
t.Logf("Resourcelink %d updated", id)
for k, v := range resp.Success {
t.Logf("%v: %s", k, v)
}
}
func TestDeleteResourcelink(t *testing.T) {
b := huego.New(hostname, username)
id := 1
err := b.DeleteResourcelink(1)
if err != nil {
t.Fatal(err)
}
t.Logf("Resourcelink %d deleted", id)
}