Ejemplo n.º 1
0
func main() {
	flag.Parse()
	if *help {
		flag.Usage()
		os.Exit(0)
	}
	c, err := agent.SetupConfig(*config, *props)
	if err != nil {
		log.Fatal(err)
	}
	if err := agent.Run(c, *restore); err != nil {
		log.Fatal(err)
	}
}
)

var tConfig common.Config

var _ = BeforeSuite(func() {

	// config for test from it-config.yml
	kii.Logger = log.New(os.Stderr, "", log.LstdFlags)
	b, err := ioutil.ReadFile("it-config.yml")
	Expect(err).NotTo(HaveOccurred())

	err = yaml.Unmarshal(b, &tConfig)
	Expect(err).NotTo(HaveOccurred())

	// run gateway-agent from gw-config.yml
	c, err := agent.SetupConfig("gw-config.yml", "props.yml")
	Expect(err).NotTo(HaveOccurred())

	tConfig.Apps["master"] = common.App{
		ID:   c.MasterApp.AppID,
		Key:  c.MasterApp.AppKey,
		Site: c.MasterApp.Site,
	}
	tConfig.GatewayAddress = common.GatewayAddress{
		Host: "127.0.0.1",
		Port: c.LocalServer.Addr.Port,
	}
	tConfig.MqttBroker = common.GatewayAddress{
		Host: "127.0.0.1",
		Port: c.Mqtt.LocalBroker.Port,
	}