forked from amimof/huego
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config_test.go
106 lines (100 loc) · 3.46 KB
/
config_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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package huego_test
import (
"github.com/amimof/huego"
"testing"
)
func TestGetConfig(t *testing.T) {
b := huego.New(hostname, username)
config, err := b.GetConfig()
if err != nil {
t.Fatal(err)
}
t.Logf("Name: %s", config.Name)
t.Logf("SwUpdate:")
t.Logf(" CheckForUpdate: %t", config.SwUpdate.CheckForUpdate)
t.Logf(" DeviceTypes:")
t.Logf(" Bridge: %t", config.SwUpdate.DeviceTypes.Bridge)
t.Logf(" Lights (length): %d", len(config.SwUpdate.DeviceTypes.Lights))
t.Logf(" Sensors (length): %d", len(config.SwUpdate.DeviceTypes.Sensors))
t.Logf(" UpdateState: %d", config.SwUpdate.UpdateState)
t.Logf(" Notify: %t", config.SwUpdate.Notify)
t.Logf(" URL: %s", config.SwUpdate.URL)
t.Logf(" Text: %s", config.SwUpdate.Text)
t.Logf("SwUpdate2:")
t.Logf(" Bridge: %s", config.SwUpdate2.Bridge)
t.Logf(" State: %s", config.SwUpdate2.Bridge.State)
t.Logf(" LastInstall: %s", config.SwUpdate2.Bridge.LastInstall)
t.Logf(" CheckForUpdate: %t", config.SwUpdate2.CheckForUpdate)
t.Logf(" State: %s", config.SwUpdate2.State)
t.Logf(" Install: %t", config.SwUpdate2.Install)
t.Logf(" AutoInstall:")
t.Logf(" On: %t", config.SwUpdate2.AutoInstall.On)
t.Logf(" UpdateTime: %s", config.SwUpdate2.AutoInstall.UpdateTime)
t.Logf(" LastChange: %s", config.SwUpdate2.LastChange)
t.Logf(" LastInstall: %s", config.SwUpdate2.LastInstall)
t.Logf("Whitelist (length): %d", len(config.Whitelist))
t.Logf("PortalState:")
t.Logf(" SignedOn: %t", config.PortalState.SignedOn)
t.Logf(" Incoming: %t", config.PortalState.Incoming)
t.Logf(" Outgoing: %t", config.PortalState.Outgoing)
t.Logf(" Communication: %s", config.PortalState.Communication)
t.Logf("APIVersion: %s", config.APIVersion)
t.Logf("SwVersion: %s", config.SwVersion)
t.Logf("ProxyAddress: %s", config.ProxyAddress)
t.Logf("ProxyPort: %d", config.ProxyPort)
t.Logf("LinkButton: %t", config.LinkButton)
t.Logf("IPAddress: %s", config.IPAddress)
t.Logf("Mac: %s", config.Mac)
t.Logf("NetMask: %s", config.NetMask)
t.Logf("Gateway: %s", config.Gateway)
t.Logf("Dhcp: %t", config.Dhcp)
t.Logf("PortalServices: %t", config.PortalServices)
t.Logf("UTC: %s", config.UTC)
t.Logf("LocalTime: %s", config.LocalTime)
t.Logf("TimeZone: %s", config.TimeZone)
t.Logf("ZigbeeChannel: %d", config.ZigbeeChannel)
t.Logf("ModelID: %s", config.ModelID)
t.Logf("BridgeID: %s", config.BridgeID)
t.Logf("FactoryNew: %t", config.FactoryNew)
t.Logf("ReplacesBridgeID: %s", config.ReplacesBridgeID)
t.Logf("DatastoreVersion: %s", config.DatastoreVersion)
t.Logf("StarterKitID: %s", config.StarterKitID)
}
func TestCreateUser(t *testing.T) {
b := huego.New(hostname, "")
u, err := b.CreateUser("github.com/amimof/huego#go test")
if err != nil {
t.Fatal(err)
} else {
t.Logf("User created with username: %s", u)
}
}
func TestGetUsers(t *testing.T) {
b := huego.New(hostname, username)
users, err := b.GetUsers()
if err != nil {
t.Fatal(err)
}
for i, u := range users {
t.Logf("%d:", i)
t.Logf(" Name: %s", u.Name)
t.Logf(" Username: %s", u.Username)
t.Logf(" CreateDate: %s", u.CreateDate)
t.Logf(" LastUseDate: %s", u.LastUseDate)
}
}
func TestDeleteUser(t *testing.T) {
b := huego.New(hostname, username)
err := b.DeleteUser("ffffffffe0341b1b376a2389376a2389")
if err != nil {
t.Fatal(err)
}
t.Logf("Deleted user '%s'", "ffffffffe0341b1b376a2389376a2389")
}
func TestGetFullState(t *testing.T) {
b := huego.New(hostname, username)
_, err := b.GetFullState()
if err != nil {
t.Fatal(err)
}
}