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) } }
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))) }