func TestInitializeContainer(t *testing.T) { cfg := new(api.Configuration) cfg.Db = "localhost:27017" cfg.MaxProcs = 1 cfg.NodeID = "LocalDev" mailConfig := new(api.MailConfig) mailConfig.Host = "smtp.gmail.com" mailConfig.User = "******" mailConfig.Pass = "******" mailConfig.Port = 579 cfg.Mail = *mailConfig container, env := Initialize("./home", *cfg) if container == nil { t.Fail() } if env == nil { t.Fail() } if container.DataSource() == nil { t.Fail() } if container.Env() == nil { t.Fail() } if container.Factory() == nil { t.Fail() } if container.ProtocolHandlers() == nil { t.Fail() } if container.RulesManager() == nil { t.Fail() } if container.ScheduleService() == nil { t.Fail() } if container.ThingManager() == nil { t.Fail() } // --------------------------------------------- }
func validateConfig(cfg *api.Configuration) { if cfg.Db == "" { log.Fatal("Database Parameter Missing") } if cfg.ServerPort == 0 { log.Println("Server port not defined. Defaulting to 8181") cfg.ServerPort = 8181 } if len(cfg.Channels) == 0 { log.Println("No channels defined. Will only work via HTTP.") } }