示例#1
0
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)
}
示例#2
0
文件: cscl.go 项目: bb/go-sonos
func initConfig(dir string) {
	if "" == dir {
		dir = path.Join(os.Getenv("HOME"), ".go-sonos")
	}
	CONFIG = config.MakeConfig(dir)
	CONFIG.Init()
}
示例#3
0
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")
	}
}
示例#4
0
文件: sonos_test.go 项目: bb/go-sonos
func initTestSonos(flags int) {
	log.SetFlags(log.Ltime | log.Lshortfile)
	c := config.MakeConfig(TEST_CONFIG)
	c.Init()
	if dev := c.Lookup(TEST_DEVICE); nil != dev {
		reactor := sonos.MakeReactor(TEST_NETWORK, TEST_EVENTING_PORT)
		testSonos = sonos.Connect(dev, reactor, flags)
	} else {
		log.Fatal("Could not create test instance")
	}
}
示例#5
0
文件: csweb.go 项目: bb/go-sonos
func main() {
	log.SetFlags(log.Ltime | log.Lshortfile)
	config := config.MakeConfig(CSWEB_CONFIG)
	config.Init()

	s := initSonos(config)
	if nil != s {
		setupHttp(s)
	}

	log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", CSWEB_HTTP_PORT), nil))
}
示例#6
0
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_NETWORK, 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")
	}
}