aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--bridge_test.go19
-rw-r--r--group_test.go15
-rw-r--r--light_test.go19
-rw-r--r--scene_test.go35
-rw-r--r--schedule_test.go29
6 files changed, 86 insertions, 32 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..1377554
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+*.swp
diff --git a/bridge_test.go b/bridge_test.go
index 04aa0d0..a28b0ab 100644
--- a/bridge_test.go
+++ b/bridge_test.go
@@ -8,26 +8,33 @@
package hue
import (
- "fmt"
+ "github.com/collinux/GoHue"
"testing"
)
func TestCreateUser(t *testing.T) {
- bridge, _ := NewBridge("192.168.1.128")
+ bridges, err := hue.FindBridges()
+ if err != nil {
+ t.Fatal(err)
+ }
+ bridge := bridges[0]
username, _ := bridge.CreateUser("test")
bridge.Login(username)
//bridge.DeleteUser(bridge.Username)
}
func TestFindBridges(t *testing.T) {
- bridges, _ := FindBridges()
- fmt.Println(bridges[0].IPAddress)
+ bridges, err := hue.FindBridges()
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Log(bridges)
}
func TestBridgeLogin(t *testing.T) {
- bridges, err := FindBridges()
+ bridges, err := hue.FindBridges()
if err != nil {
- fmt.Println("Error on TestBridgeLogin")
+ t.Fatal(err)
}
bridges[0].Login("427de8bd6d49f149c8398e4fc08f")
diff --git a/group_test.go b/group_test.go
index 58b74bc..41f612f 100644
--- a/group_test.go
+++ b/group_test.go
@@ -8,15 +8,20 @@
package hue
import (
- "fmt"
+ "github.com/collinux/GoHue"
"testing"
)
func TestGetGroups(t *testing.T) {
- bridge, _ := NewBridge("192.168.1.128")
+ bridges, err := hue.FindBridges()
+ if err != nil {
+ t.Fatal(err)
+ }
+ bridge := bridges[0]
bridge.Login("427de8bd6d49f149c8398e4fc08f")
- groups, _ := bridge.GetGroups()
- for group := range groups {
- fmt.Println(groups[group])
+ groups, err := bridge.GetGroups()
+ if err != nil {
+ t.Fatal(err)
}
+ t.Log(groups)
}
diff --git a/light_test.go b/light_test.go
index fb8eb4c..9b4486e 100644
--- a/light_test.go
+++ b/light_test.go
@@ -8,13 +8,17 @@
package hue
import (
+ "github.com/collinux/GoHue"
"testing"
- //"fmt"
"time"
)
func TestSetLightState(t *testing.T) {
- bridge, _ := NewBridge("192.168.1.128")
+ bridges, err := hue.FindBridges()
+ if err != nil {
+ t.Fatal(err)
+ }
+ bridge := bridges[0]
bridge.Login("427de8bd6d49f149c8398e4fc08f")
nameTest, _ := bridge.GetLightByName("Desk Light") // Also tests GetAllLights
_ = nameTest
@@ -59,7 +63,14 @@ func TestSetLightState(t *testing.T) {
}
func TestFindNewLights(t *testing.T) {
- bridge, _ := NewBridge("192.168.1.128")
+ bridges, err := hue.FindBridges()
+ if err != nil {
+ t.Fatal(err)
+ }
+ bridge := bridges[0]
bridge.Login("427de8bd6d49f149c8398e4fc08f")
- bridge.FindNewLights()
+ err = bridge.FindNewLights()
+ if err != nil {
+ t.Fatal(err)
+ }
}
diff --git a/scene_test.go b/scene_test.go
index 1eff2ac..ba0d952 100644
--- a/scene_test.go
+++ b/scene_test.go
@@ -8,26 +8,35 @@
package hue
import (
+ "github.com/collinux/GoHue"
"testing"
- //"fmt"
)
func TestGetAllScenes(t *testing.T) {
- bridge, _ := NewBridge("192.168.1.128")
+ bridges, err := hue.FindBridges()
+ if err != nil {
+ t.Fatal(err)
+ }
+ bridge := bridges[0]
bridge.Login("427de8bd6d49f149c8398e4fc08f")
- scenes, _ := bridge.GetAllScenes()
- // for scene := range scenes {
- // fmt.Println("SCENE: ", scenes[scene])
- // }
-
- individual, _ := bridge.GetScene(scenes[0].ID)
- _ = individual
- //fmt.Println("Individual scene: ", individual)
+ scenes, err := bridge.GetAllScenes()
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Log(scenes)
}
+// TODO not functional
func TestCreateScene(t *testing.T) {
- bridge, _ := NewBridge("192.168.1.128")
+ bridges, err := hue.FindBridges()
+ if err != nil {
+ t.Fatal(err)
+ }
+ bridge := bridges[0]
bridge.Login("427de8bd6d49f149c8398e4fc08f")
- scene := Scene{Lights: []string{"1", "2"}}
- _ = bridge.CreateScene(scene)
+ scene := hue.Scene{Name: "Testing", Lights: []string{"1", "2"}}
+ err = bridge.CreateScene(scene)
+ if err != nil {
+ t.Fatal(err)
+ }
}
diff --git a/schedule_test.go b/schedule_test.go
index 0039c6b..f1235af 100644
--- a/schedule_test.go
+++ b/schedule_test.go
@@ -8,19 +8,40 @@
package hue
import (
+ "github.com/collinux/GoHue"
"testing"
)
func TestGetAllSchedules(t *testing.T) {
- bridge, _ := NewBridge("192.168.1.128")
+ bridges, err := hue.FindBridges()
+ if err != nil {
+ t.Fatal(err)
+ }
+ bridge := bridges[0]
bridge.Login("427de8bd6d49f149c8398e4fc08f")
- _, _ = bridge.GetAllSchedules()
+ schedules, err := bridge.GetAllSchedules()
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Log(schedules)
}
func TestGetSchedule(t *testing.T) {
- bridge, _ := NewBridge("192.168.1.128")
+ bridges, err := hue.FindBridges()
+ if err != nil {
+ t.Fatal(err)
+ }
+ bridge := bridges[0]
bridge.Login("427de8bd6d49f149c8398e4fc08f")
- _, _ = bridge.GetSchedule("4673980164949558")
+ schedules, err := bridge.GetAllSchedules()
+ if err != nil {
+ t.Fatal(err)
+ }
+ schedule, err := bridge.GetSchedule(schedules[0].ID)
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Log(schedule)
}
// func TestCreateSchedule(t *testing.T) {