mirror of
https://github.com/gosticks/go-hue-interface.git
synced 2025-10-16 11:45:35 +00:00
add toggle light test
This commit is contained in:
parent
1310fcfc0b
commit
fd39c97b87
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/gosticks/go-hue-interface/utils"
|
"github.com/gosticks/go-hue-interface/utils"
|
||||||
)
|
)
|
||||||
@ -16,6 +17,33 @@ func TestParseLights(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestLightToggle(t *testing.T) {
|
||||||
|
userID, okUser := os.LookupEnv("HUE_BRIDGE_USER")
|
||||||
|
addr, okAddr := os.LookupEnv("HUE_BRIDGE_ADDR")
|
||||||
|
if !okAddr || !okUser {
|
||||||
|
fmt.Println("HUE_BRIDGE_USER and HUE_BRIDGE_ADDR must be set in env for this test to work")
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
|
||||||
|
conf := &Config{
|
||||||
|
Username: userID,
|
||||||
|
BridgeAddr: addr,
|
||||||
|
BridgeAddrScheme: "http",
|
||||||
|
}
|
||||||
|
b := NewBridge(conf)
|
||||||
|
|
||||||
|
ticker := time.NewTicker(200 * time.Millisecond)
|
||||||
|
defer ticker.Stop()
|
||||||
|
go func() {
|
||||||
|
var state = true
|
||||||
|
for range ticker.C {
|
||||||
|
b.ToggleLight("2", state)
|
||||||
|
state = !state
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
select {}
|
||||||
|
}
|
||||||
func TestBridgeLightsParse(t *testing.T) {
|
func TestBridgeLightsParse(t *testing.T) {
|
||||||
userID, okUser := os.LookupEnv("HUE_BRIDGE_USER")
|
userID, okUser := os.LookupEnv("HUE_BRIDGE_USER")
|
||||||
addr, okAddr := os.LookupEnv("HUE_BRIDGE_ADDR")
|
addr, okAddr := os.LookupEnv("HUE_BRIDGE_ADDR")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user