func openRooms(configPath string) { var cherryRooms *config.CherryRooms var err *parser.CherryFileError cherryRooms, err = parser.ParseCherryFile(configPath) if err != nil { fmt.Println(err.Error()) os.Exit(1) } else { rooms := cherryRooms.GetRooms() for _, r := range rooms { go messageplexer.RoomMessagePlexer(r, cherryRooms) go peer(r, cherryRooms) } } sigintWatchdog := make(chan os.Signal, 1) signal.Notify(sigintWatchdog, os.Interrupt) signal.Notify(sigintWatchdog, syscall.SIGINT|syscall.SIGTERM) <-sigintWatchdog cleanup() }
func PreprocessorBasicTest(t *testing.T) { preprocessor := html.NewHTMLPreprocessor(nil) if preprocessor.ExpandData("land-of-competition", "{{.FoD}} Zzz...") != "{{.FoD}} Zzz..." { t.Fail() } var cherry_rooms *config.CherryRooms cwd, _ := os.Getwd() os.Chdir("../../sample") var error *parser.CherryFileError cherry_rooms, error = parser.ParseCherryFile("conf/sample.cherry") os.Chdir(cwd) if error != nil { t.Fail() } preprocessor.Init(cherry_rooms) preprocessor.SetDataValue("{{.foo}}", "bar") preprocessor.SetDataValue("{{.bar}}", "foo") if preprocessor.ExpandData("aliens-on-earth", "{{.foo}}{{.bar}}") != "barfoo" { t.Fail() } if preprocessor.ExpandData("aliens-on-earth", "{{.greeting-message}}") != "Take meeeeee to your leader!!!" { t.Fail() } }