func Run(port int) { defer storage.Close() channelStore = storage.NewChannelStore() sessions = make(map[string]*Session) reconnect() log.Println("Listening on port", port) log.Fatal(http.ListenAndServe(":"+strconv.Itoa(port), handler{})) }
func TestMain(m *testing.M) { tempdir, err := ioutil.TempDir("", "test_") if err != nil { log.Fatal(err) } os.Mkdir(path.Join(tempdir, "logs"), 0777) storage.Initialize(tempdir) user = storage.NewUser("uuid") channelStore = storage.NewChannelStore() code := m.Run() os.RemoveAll(tempdir) os.Exit(code) }