func TestConfig(t *testing.T) { log.SetFlags(log.Ltime | log.Lshortfile) if err := os.RemoveAll(configdir); nil != err { panic(err) } c := config.MakeConfig(configdir) c.Init() c.AddBookmark(uuid, sonos.SONOS, location, uuid) c.AddAlias(uuid, alias) c.Save() c = nil d := config.MakeConfig(configdir) d.Init() bookmark := d.Bookmarks[uuid] if location != bookmark.Location { panic("failed") } if dev := d.Lookup(alias); nil == dev { panic("failed") } os.RemoveAll(configdir) }
func initConfig(dir string) { if "" == dir { dir = path.Join(os.Getenv("HOME"), ".go-sonos") } CONFIG = config.MakeConfig(dir) CONFIG.Init() }
func initTestReciva(flags int) { log.SetFlags(log.Ltime | log.Lshortfile) c := config.MakeConfig(TEST_CONFIG) c.Init() if dev := c.Lookup(TEST_RECIVA); nil != dev { testReciva = sonos.ConnectReciva(dev, nil, flags) } else { log.Fatal("Could not create test instance") } }
func main() { log.SetFlags(log.Ltime | log.Lshortfile) config := config.MakeConfig(CSWEB_CONFIG) config.Init() s := initSonos(config) if nil != s { setupHttp(s) } log.Printf("Starting server loop ...") log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", CSWEB_HTTP_PORT), nil)) }
func TestEvent(t *testing.T) { // Startup and listen to events log.SetFlags(log.Ltime | log.Lshortfile) c := config.MakeConfig(TEST_CONFIG) c.Init() if dev := c.Lookup(TEST_SONOS); nil != dev { exit_chan := make(chan bool) reactor := sonos.MakeReactor(TEST_EVENTING_PORT) go handleEvent_TestEventBrief(reactor, exit_chan) testSonos = sonos.Connect(dev, reactor, sonos.SVC_ALL) <-exit_chan } else { log.Fatal("Could not create test instance") } }