Esempio n. 1
0
func TestUserIndex(t *testing.T) {
	req, _ := http.NewRequest("GET", "/admin/users", nil)
	w := httptest.NewRecorder()
	shared.Init()
	UserIndex(w, req)
	if w.Code != http.StatusOK {
		t.Errorf("/admin/users didn't return %v\n", http.StatusOK)
	}
}
Esempio n. 2
0
func main() {
	migrate := flag.String("migrate", "skip", "Run DB migrations: up, down, redo, new [MIGRATION_NAME] and then os.Exit(0)")
	mode := flag.String("mode", "debug", "Application mode: debug, release, test")
	flag.Parse()

	shared.SetMode(mode)
	shared.Init()
	shared.RunMigrations(migrate)

	//Periodic tasks
	gocron.Every(1).Day().Do(shared.CreateXMLSitemap)
	gocron.Start()

	routes.Init()

	log.Printf("Listening on :%d port in %q mode\n", 8080, *mode)
	log.Fatal(http.ListenAndServe(":8080", context.ClearHandler(http.DefaultServeMux)))
}