added end to end encoding test with a hue

This commit is contained in:
Wlad Meixner 2019-02-15 23:36:08 +01:00
parent b52a03caad
commit 1199c755c4

View File

@ -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": {