mirror of
https://github.com/gosticks/go-hue-interface.git
synced 2025-10-16 11:45:35 +00:00
added end to end encoding test with a hue
This commit is contained in:
parent
b52a03caad
commit
1199c755c4
@ -1,6 +1,8 @@
|
||||
package hue
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/gosticks/go-hue-interface/utils"
|
||||
@ -14,6 +16,38 @@ func TestParseGroups(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestBridgeGroupsParse(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)
|
||||
resp, respErr := b.getRawResponse(groupsEndpoint)
|
||||
if respErr != nil {
|
||||
t.Log(respErr)
|
||||
t.Error()
|
||||
}
|
||||
|
||||
groups, errGroups := b.GetAllGroups()
|
||||
if errGroups != nil {
|
||||
t.Log(errGroups)
|
||||
t.Error()
|
||||
}
|
||||
|
||||
errComp := utils.CompareStructToJSON(groups, string(resp))
|
||||
if errComp != nil {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
const groupsTestData = `
|
||||
{
|
||||
"1": {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user