diff --git a/internal/handlers/handlers.go b/internal/handlers/handlers.go index 80d545f..9880173 100644 --- a/internal/handlers/handlers.go +++ b/internal/handlers/handlers.go @@ -67,14 +67,14 @@ func (m *Repository) Reservation(w http.ResponseWriter, r *http.Request) { res, ok := m.App.Session.Get(r.Context(), "reservation").(models.Reservation) if !ok { m.App.Session.Put(r.Context(), "error", "can't get reservation from session") - http.Redirect(w, r, "/", http.StatusTemporaryRedirect) + http.Redirect(w, r, "/", http.StatusSeeOther) return } room, err := m.DB.GetRoomById(res.RoomID) if err != nil { m.App.Session.Put(r.Context(), "error", "can't find room!") - http.Redirect(w, r, "/", http.StatusTemporaryRedirect) + http.Redirect(w, r, "/", http.StatusSeeOther) return } @@ -104,7 +104,7 @@ func (m *Repository) PostReservation(w http.ResponseWriter, r *http.Request) { err := r.ParseForm() if err != nil { m.App.Session.Put(r.Context(), "error", "can't parse form!") - http.Redirect(w, r, "/", http.StatusTemporaryRedirect) + http.Redirect(w, r, "/", http.StatusSeeOther) return } @@ -117,21 +117,28 @@ func (m *Repository) PostReservation(w http.ResponseWriter, r *http.Request) { startDate, err := time.Parse(layout, sd) if err != nil { m.App.Session.Put(r.Context(), "error", "can't parse start date") - http.Redirect(w, r, "/", http.StatusTemporaryRedirect) + http.Redirect(w, r, "/", http.StatusSeeOther) return } endDate, err := time.Parse(layout, ed) if err != nil { m.App.Session.Put(r.Context(), "error", "can't parse end date") - http.Redirect(w, r, "/", http.StatusTemporaryRedirect) + http.Redirect(w, r, "/", http.StatusSeeOther) return } roomID, err := strconv.Atoi(r.Form.Get("room_id")) if err != nil { m.App.Session.Put(r.Context(), "error", "invalid data!") - http.Redirect(w, r, "/", http.StatusTemporaryRedirect) + http.Redirect(w, r, "/", http.StatusSeeOther) + return + } + + room, err := m.DB.GetRoomById(roomID) + if err != nil { + m.App.Session.Put(r.Context(), "error", "invalid data!") + http.Redirect(w, r, "/", http.StatusSeeOther) return } @@ -143,6 +150,7 @@ func (m *Repository) PostReservation(w http.ResponseWriter, r *http.Request) { StartDate: startDate, EndDate: endDate, RoomID: roomID, + Room: room, } form := forms.New(r.PostForm) @@ -154,7 +162,6 @@ func (m *Repository) PostReservation(w http.ResponseWriter, r *http.Request) { if !form.Valid() { data := make(map[string]interface{}) data["reservation"] = reservation - http.Error(w, "my own message", http.StatusSeeOther) render.Template(w, r, "make-reservation.page.html", &models.TemplateData{ Form: form, Data: data, @@ -165,7 +172,7 @@ func (m *Repository) PostReservation(w http.ResponseWriter, r *http.Request) { newReservationID, err := m.DB.InsertReservation(reservation) if err != nil { m.App.Session.Put(r.Context(), "error", "can't insert reservation into database!") - http.Redirect(w, r, "/", http.StatusTemporaryRedirect) + http.Redirect(w, r, "/", http.StatusSeeOther) return } @@ -180,7 +187,7 @@ func (m *Repository) PostReservation(w http.ResponseWriter, r *http.Request) { err = m.DB.InsertRoomRestriction(restriction) if err != nil { m.App.Session.Put(r.Context(), "error", "can't insert room restriction!") - http.Redirect(w, r, "/", http.StatusTemporaryRedirect) + http.Redirect(w, r, "/", http.StatusSeeOther) return } @@ -241,7 +248,7 @@ func (m *Repository) PostAvailability(w http.ResponseWriter, r *http.Request) { err := r.ParseForm() if err != nil { m.App.Session.Put(r.Context(), "error", "can't parse form!") - http.Redirect(w, r, "/", http.StatusTemporaryRedirect) + http.Redirect(w, r, "/", http.StatusSeeOther) return } @@ -252,20 +259,20 @@ func (m *Repository) PostAvailability(w http.ResponseWriter, r *http.Request) { startDate, err := time.Parse(layout, start) if err != nil { m.App.Session.Put(r.Context(), "error", "can't parse start date!") - http.Redirect(w, r, "/", http.StatusTemporaryRedirect) + http.Redirect(w, r, "/", http.StatusSeeOther) return } endDate, err := time.Parse(layout, end) if err != nil { m.App.Session.Put(r.Context(), "error", "can't parse end date!") - http.Redirect(w, r, "/", http.StatusTemporaryRedirect) + http.Redirect(w, r, "/", http.StatusSeeOther) return } rooms, err := m.DB.SearchAvailabilityForAllRooms(startDate, endDate) if err != nil { m.App.Session.Put(r.Context(), "error", "can't get availability for rooms") - http.Redirect(w, r, "/", http.StatusTemporaryRedirect) + http.Redirect(w, r, "/", http.StatusSeeOther) return } @@ -388,7 +395,7 @@ func (m *Repository) ReservationSummary(w http.ResponseWriter, r *http.Request) reservation, ok := m.App.Session.Get(r.Context(), "reservation").(models.Reservation) if !ok { m.App.Session.Put(r.Context(), "error", "Can't get reservation from session") - http.Redirect(w, r, "/", http.StatusTemporaryRedirect) + http.Redirect(w, r, "/", http.StatusSeeOther) return } @@ -416,7 +423,7 @@ func (m *Repository) ChooseRoom(w http.ResponseWriter, r *http.Request) { //if err != nil { // log.Println(err) // m.App.Session.Put(r.Context(), "error", "missing url parameter") - // http.Redirect(w, r, "/", http.StatusTemporaryRedirect) + // http.Redirect(w, r, "/", http.StatusSeeOther) // return //} @@ -426,14 +433,14 @@ func (m *Repository) ChooseRoom(w http.ResponseWriter, r *http.Request) { roomID, err := strconv.Atoi(exploded[2]) if err != nil { m.App.Session.Put(r.Context(), "error", "missing url parameter") - http.Redirect(w, r, "/", http.StatusTemporaryRedirect) + http.Redirect(w, r, "/", http.StatusSeeOther) return } res, ok := m.App.Session.Get(r.Context(), "reservation").(models.Reservation) if !ok { m.App.Session.Put(r.Context(), "error", "Can't get reservation from session") - http.Redirect(w, r, "/", http.StatusTemporaryRedirect) + http.Redirect(w, r, "/", http.StatusSeeOther) return } @@ -454,13 +461,13 @@ func (m *Repository) BookRoom(w http.ResponseWriter, r *http.Request) { startDate, err := time.Parse(layout, sd) if err != nil { m.App.Session.Put(r.Context(), "error", "can't parse start date!") - http.Redirect(w, r, "/", http.StatusTemporaryRedirect) + http.Redirect(w, r, "/", http.StatusSeeOther) return } endDate, err := time.Parse(layout, ed) if err != nil { m.App.Session.Put(r.Context(), "error", "can't parse end date!") - http.Redirect(w, r, "/", http.StatusTemporaryRedirect) + http.Redirect(w, r, "/", http.StatusSeeOther) return } @@ -469,7 +476,7 @@ func (m *Repository) BookRoom(w http.ResponseWriter, r *http.Request) { room, err := m.DB.GetRoomById(roomID) if err != nil { m.App.Session.Put(r.Context(), "error", "Can't get room from db!") - http.Redirect(w, r, "/", http.StatusTemporaryRedirect) + http.Redirect(w, r, "/", http.StatusSeeOther) return } @@ -515,8 +522,6 @@ func (m *Repository) PostShowLogin(w http.ResponseWriter, r *http.Request) { id, _, err := m.DB.Authenticate(email, password) if err != nil { - log.Println(err) - m.App.Session.Put(r.Context(), "error", "Invalid login credentials") http.Redirect(w, r, "/user/login", http.StatusSeeOther) return diff --git a/internal/handlers/handlers_test.go b/internal/handlers/handlers_test.go index 7fc89e9..f67bc03 100644 --- a/internal/handlers/handlers_test.go +++ b/internal/handlers/handlers_test.go @@ -32,7 +32,14 @@ var theTests = []struct { {"ms", "/majors-suite", "GET", http.StatusOK}, {"sa", "/search-availability", "GET", http.StatusOK}, {"contact", "/contact", "GET", http.StatusOK}, - + {"non-existent", "/green/eggs/and/ham", "GET", http.StatusNotFound}, + // new routes + {"login", "/user/login", "GET", http.StatusOK}, + {"logout", "/user/logout", "GET", http.StatusOK}, + {"dashboard", "/admin/dashboard", "GET", http.StatusOK}, + {"new res", "/admin/reservations-new", "GET", http.StatusOK}, + {"all res", "/admin/reservations-all", "GET", http.StatusOK}, + {"show res", "/admin/reservations/new/1/show", "GET", http.StatusOK}, // {"post-search-avail", "/search-availability", "POST", []postData{ // {key: "start", value: "2020-01-01"}, // {key: "end", value: "2020-01-02"}, @@ -91,8 +98,8 @@ func TestRepository_Reservation(t *testing.T) { rr = httptest.NewRecorder() handler.ServeHTTP(rr, req) - if rr.Code != http.StatusTemporaryRedirect { - t.Errorf("Reservation handler returned wrong response code: got %d, wanted %d", rr.Code, http.StatusTemporaryRedirect) + if rr.Code != http.StatusSeeOther { + t.Errorf("Reservation handler returned wrong response code: got %d, wanted %d", rr.Code, http.StatusSeeOther) } // test with non-existent room @@ -104,7 +111,7 @@ func TestRepository_Reservation(t *testing.T) { session.Put(ctx, "reservation", reservation) handler.ServeHTTP(rr, req) - if rr.Code != http.StatusTemporaryRedirect { + if rr.Code != http.StatusSeeOther { t.Errorf("Reservation handler returned wrong response code: got %d, wanted %d", rr.Code, http.StatusOK) } } @@ -146,8 +153,8 @@ func TestRepository_PostReservation(t *testing.T) { handler.ServeHTTP(rr, req) - if rr.Code != http.StatusTemporaryRedirect { - t.Errorf("Reservation handler returned wrong response code for missing post body: got %d, wanted %d", rr.Code, http.StatusTemporaryRedirect) + if rr.Code != http.StatusSeeOther { + t.Errorf("Reservation handler returned wrong response code for missing post body: got %d, wanted %d", rr.Code, http.StatusSeeOther) } // test for invalid start date @@ -170,8 +177,8 @@ func TestRepository_PostReservation(t *testing.T) { handler.ServeHTTP(rr, req) - if rr.Code != http.StatusTemporaryRedirect { - t.Errorf("Reservation handler returned wrong response code for invalid start date: got %d, wanted %d", rr.Code, http.StatusTemporaryRedirect) + if rr.Code != http.StatusSeeOther { + t.Errorf("Reservation handler returned wrong response code for invalid start date: got %d, wanted %d", rr.Code, http.StatusSeeOther) } // test for invalid end date @@ -194,8 +201,8 @@ func TestRepository_PostReservation(t *testing.T) { handler.ServeHTTP(rr, req) - if rr.Code != http.StatusTemporaryRedirect { - t.Errorf("Reservation handler returned wrong response code for invalid end date: got %d, wanted %d", rr.Code, http.StatusTemporaryRedirect) + if rr.Code != http.StatusSeeOther { + t.Errorf("Reservation handler returned wrong response code for invalid end date: got %d, wanted %d", rr.Code, http.StatusSeeOther) } // test for invalid room id @@ -218,8 +225,8 @@ func TestRepository_PostReservation(t *testing.T) { handler.ServeHTTP(rr, req) - if rr.Code != http.StatusTemporaryRedirect { - t.Errorf("Reservation handler returned wrong response code for invalid room id: got %d, wanted %d", rr.Code, http.StatusTemporaryRedirect) + if rr.Code != http.StatusSeeOther { + t.Errorf("Reservation handler returned wrong response code for invalid room id: got %d, wanted %d", rr.Code, http.StatusSeeOther) } // test for invalid data @@ -242,7 +249,7 @@ func TestRepository_PostReservation(t *testing.T) { handler.ServeHTTP(rr, req) - if rr.Code != http.StatusSeeOther { + if rr.Code != http.StatusOK { t.Errorf("Reservation handler returned wrong response code for invalid data: got %d, wanted %d", rr.Code, http.StatusSeeOther) } @@ -266,8 +273,8 @@ func TestRepository_PostReservation(t *testing.T) { handler.ServeHTTP(rr, req) - if rr.Code != http.StatusTemporaryRedirect { - t.Errorf("Reservation handler failed when trying to fail inserting reservation: got %d, wanted %d", rr.Code, http.StatusTemporaryRedirect) + if rr.Code != http.StatusSeeOther { + t.Errorf("Reservation handler failed when trying to fail inserting reservation: got %d, wanted %d", rr.Code, http.StatusSeeOther) } // test for failure to insert restriction into database @@ -290,8 +297,8 @@ func TestRepository_PostReservation(t *testing.T) { handler.ServeHTTP(rr, req) - if rr.Code != http.StatusTemporaryRedirect { - t.Errorf("Reservation handler failed when trying to fail inserting restriction: got %d, wanted %d", rr.Code, http.StatusTemporaryRedirect) + if rr.Code != http.StatusSeeOther { + t.Errorf("Reservation handler failed when trying to fail inserting restriction: got %d, wanted %d", rr.Code, http.StatusSeeOther) } } @@ -395,9 +402,9 @@ func TestRepository_PostAvailability(t *testing.T) { // make the request to our handler handler.ServeHTTP(rr, req) - // since we have rooms available, we expect to get status http.StatusTemporaryRedirect - if rr.Code != http.StatusTemporaryRedirect { - t.Errorf("Post availability with empty request body (nil) gave wrong status code: got %d, wanted %d", rr.Code, http.StatusTemporaryRedirect) + // since we have rooms available, we expect to get status http.StatusSeeOther + if rr.Code != http.StatusSeeOther { + t.Errorf("Post availability with empty request body (nil) gave wrong status code: got %d, wanted %d", rr.Code, http.StatusSeeOther) } /***************************************** @@ -426,9 +433,9 @@ func TestRepository_PostAvailability(t *testing.T) { // make the request to our handler handler.ServeHTTP(rr, req) - // since we have rooms available, we expect to get status http.StatusTemporaryRedirect - if rr.Code != http.StatusTemporaryRedirect { - t.Errorf("Post availability with invalid start date gave wrong status code: got %d, wanted %d", rr.Code, http.StatusTemporaryRedirect) + // since we have rooms available, we expect to get status http.StatusSeeOther + if rr.Code != http.StatusSeeOther { + t.Errorf("Post availability with invalid start date gave wrong status code: got %d, wanted %d", rr.Code, http.StatusSeeOther) } /***************************************** @@ -457,9 +464,9 @@ func TestRepository_PostAvailability(t *testing.T) { // make the request to our handler handler.ServeHTTP(rr, req) - // since we have rooms available, we expect to get status http.StatusTemporaryRedirect - if rr.Code != http.StatusTemporaryRedirect { - t.Errorf("Post availability with invalid end date gave wrong status code: got %d, wanted %d", rr.Code, http.StatusTemporaryRedirect) + // since we have rooms available, we expect to get status http.StatusSeeOther + if rr.Code != http.StatusSeeOther { + t.Errorf("Post availability with invalid end date gave wrong status code: got %d, wanted %d", rr.Code, http.StatusSeeOther) } /***************************************** @@ -489,9 +496,9 @@ func TestRepository_PostAvailability(t *testing.T) { // make the request to our handler handler.ServeHTTP(rr, req) - // since we have rooms available, we expect to get status http.StatusTemporaryRedirect - if rr.Code != http.StatusTemporaryRedirect { - t.Errorf("Post availability when database query fails gave wrong status code: got %d, wanted %d", rr.Code, http.StatusTemporaryRedirect) + // since we have rooms available, we expect to get status http.StatusSeeOther + if rr.Code != http.StatusSeeOther { + t.Errorf("Post availability when database query fails gave wrong status code: got %d, wanted %d", rr.Code, http.StatusSeeOther) } } @@ -773,7 +780,7 @@ func TestRepository_ReservationSummary(t *testing.T) { handler.ServeHTTP(rr, req) - if rr.Code != http.StatusTemporaryRedirect { + if rr.Code != http.StatusSeeOther { t.Errorf("ReservationSummary handler returned wrong response code: got %d, wanted %d", rr.Code, http.StatusOK) } } @@ -805,7 +812,7 @@ func TestRepository_ChooseRoom(t *testing.T) { handler.ServeHTTP(rr, req) if rr.Code != http.StatusSeeOther { - t.Errorf("ChooseRoom handler returned wrong response code: got %d, wanted %d", rr.Code, http.StatusTemporaryRedirect) + t.Errorf("ChooseRoom handler returned wrong response code: got %d, wanted %d", rr.Code, http.StatusSeeOther) } ///***************************************** @@ -822,8 +829,8 @@ func TestRepository_ChooseRoom(t *testing.T) { handler.ServeHTTP(rr, req) - if rr.Code != http.StatusTemporaryRedirect { - t.Errorf("ChooseRoom handler returned wrong response code: got %d, wanted %d", rr.Code, http.StatusTemporaryRedirect) + if rr.Code != http.StatusSeeOther { + t.Errorf("ChooseRoom handler returned wrong response code: got %d, wanted %d", rr.Code, http.StatusSeeOther) } ///***************************************** @@ -840,8 +847,8 @@ func TestRepository_ChooseRoom(t *testing.T) { handler.ServeHTTP(rr, req) - if rr.Code != http.StatusTemporaryRedirect { - t.Errorf("ChooseRoom handler returned wrong response code: got %d, wanted %d", rr.Code, http.StatusTemporaryRedirect) + if rr.Code != http.StatusSeeOther { + t.Errorf("ChooseRoom handler returned wrong response code: got %d, wanted %d", rr.Code, http.StatusSeeOther) } } @@ -885,8 +892,8 @@ func TestRepository_BookRoom(t *testing.T) { handler.ServeHTTP(rr, req) - if rr.Code != http.StatusTemporaryRedirect { - t.Errorf("BookRoom handler returned wrong response code: got %d, wanted %d", rr.Code, http.StatusTemporaryRedirect) + if rr.Code != http.StatusSeeOther { + t.Errorf("BookRoom handler returned wrong response code: got %d, wanted %d", rr.Code, http.StatusSeeOther) } /***************************************** @@ -911,8 +918,8 @@ func TestRepository_BookRoom(t *testing.T) { handler.ServeHTTP(rr, req) - if rr.Code != http.StatusTemporaryRedirect { - t.Errorf("BookRoom handler returned wrong response code: got %d, wanted %d", rr.Code, http.StatusTemporaryRedirect) + if rr.Code != http.StatusSeeOther { + t.Errorf("BookRoom handler returned wrong response code: got %d, wanted %d", rr.Code, http.StatusSeeOther) } /***************************************** @@ -937,8 +944,82 @@ func TestRepository_BookRoom(t *testing.T) { handler.ServeHTTP(rr, req) - if rr.Code != http.StatusTemporaryRedirect { - t.Errorf("BookRoom handler returned wrong response code: got %d, wanted %d", rr.Code, http.StatusTemporaryRedirect) + if rr.Code != http.StatusSeeOther { + t.Errorf("BookRoom handler returned wrong response code: got %d, wanted %d", rr.Code, http.StatusSeeOther) + } +} + +// loginTests is the data for the Login handler tests +var loginTests = []struct { + name string + email string + expectedStatusCode int + expectedHTML string + expectedLocation string +}{ + { + "valid-credentials", + "me@here.ca", + http.StatusSeeOther, + "", + "/", + }, + { + "invalid-credentials", + "jack@nimble.com", + http.StatusSeeOther, + "", + "/user/login", + }, + // { + // "invalid-data", + // "j", + // http.StatusOK, + // `action="/user/login"`, + // "", + // }, +} + +func TestLogin(t *testing.T) { + // range through all tests + for _, e := range loginTests { + postedData := url.Values{} + postedData.Add("email", e.email) + postedData.Add("password", "password") + + // create request + req, _ := http.NewRequest("POST", "/user/login", strings.NewReader(postedData.Encode())) + ctx := getCtx(req) + req = req.WithContext(ctx) + + // set the header + req.Header.Set("Content-Type", "application/x-www-form-urlencoded") + rr := httptest.NewRecorder() + + // call the handler + handler := http.HandlerFunc(Repo.PostShowLogin) + handler.ServeHTTP(rr, req) + + if rr.Code != e.expectedStatusCode { + t.Errorf("failed %s: expected code %d, but got %d", e.name, e.expectedStatusCode, rr.Code) + } + + if e.expectedLocation != "" { + // get the URL from test + actualLoc, _ := rr.Result().Location() + if actualLoc.String() != e.expectedLocation { + t.Errorf("failed %s: expected location %s, but got location %s", e.name, e.expectedLocation, actualLoc.String()) + } + } + + // checking for expected values in HTML + if e.expectedHTML != "" { + // read the response body into a string + html := rr.Body.String() + if !strings.Contains(html, e.expectedHTML) { + t.Errorf("failed %s: expected to find %s but did not", e.name, e.expectedHTML) + } + } } } diff --git a/internal/handlers/setup_test.go b/internal/handlers/setup_test.go index 8d1d474..cca4983 100644 --- a/internal/handlers/setup_test.go +++ b/internal/handlers/setup_test.go @@ -23,10 +23,20 @@ import ( var app config.AppConfig var session *scs.SessionManager var pathToTemplates = "./../../templates" -var functions = template.FuncMap{} + +var functions = template.FuncMap{ + "humanDate": render.HumanDate, + "formatDate": render.FormatDate, + "iterate": render.Iterate, + "add": render.Add, +} func TestMain(m *testing.M) { gob.Register(models.Reservation{}) + gob.Register(models.User{}) + gob.Register(models.Room{}) + gob.Register(models.Restriction{}) + gob.Register(map[string]int{}) // change this to true when in production app.InProduction = false @@ -78,7 +88,7 @@ func getRoutes() http.Handler { mux := chi.NewRouter() mux.Use(middleware.Recoverer) - // mux.Use(NoSurf) + //mux.Use(NoSurf) mux.Use(SessionLoad) mux.Get("/", Repo.Home) @@ -96,6 +106,22 @@ func getRoutes() http.Handler { mux.Post("/make-reservation", Repo.PostReservation) mux.Get("/reservation-summary", Repo.ReservationSummary) + mux.Get("/user/login", Repo.ShowLogin) + mux.Post("/user/login", Repo.PostShowLogin) + mux.Get("/user/logout", Repo.Logout) + + mux.Get("/admin/dashboard", Repo.AdminDashboard) + + mux.Get("/admin/reservations-new", Repo.AdminNewReservations) + mux.Get("/admin/reservations-all", Repo.AdminAllReservations) + mux.Get("/admin/reservations-calendar", Repo.AdminReservationsCalendar) + mux.Post("/admin/reservations-calendar", Repo.AdminPostReservationsCalendar) + mux.Get("/admin/process-reservation/{src}/{id}/do", Repo.AdminProcessReservation) + mux.Get("/admin/delete-reservation/{src}/{id}/do", Repo.AdminDeleteReservation) + + mux.Get("/admin/reservations/{src}/{id}/show", Repo.AdminShowReservation) + mux.Post("/admin/reservations/{src}/{id}", Repo.AdminPostShowReservation) + fileServer := http.FileServer(http.Dir("./static/")) mux.Handle("/static/*", http.StripPrefix("/static", fileServer)) diff --git a/internal/render/render.go b/internal/render/render.go index ffe0285..c3ce453 100644 --- a/internal/render/render.go +++ b/internal/render/render.go @@ -16,7 +16,7 @@ import ( var functions = template.FuncMap{ "humanDate": HumanDate, - "formatDate": formatDate, + "formatDate": FormatDate, "iterate": Iterate, "add": Add, } @@ -48,8 +48,8 @@ func HumanDate(t time.Time) string { return t.Format("2006-01-02") } -// formatDate -func formatDate(t time.Time, f string) string { +// FormatDate +func FormatDate(t time.Time, f string) string { return t.Format(f) } diff --git a/internal/repository/dbrepo/test-repo.go b/internal/repository/dbrepo/test-repo.go index ad22b48..5ba6b8e 100644 --- a/internal/repository/dbrepo/test-repo.go +++ b/internal/repository/dbrepo/test-repo.go @@ -114,7 +114,10 @@ func (m *testDBRepo) UpdateUser(u models.User) error { } func (m *testDBRepo) Authenticate(email, testPassword string) (int, string, error) { - return 1, "", nil + if email == "me@here.ca" { + return 1, "", nil + } + return 0, "", errors.New("some error") } func (m *testDBRepo) AllReservations() ([]models.Reservation, error) { diff --git a/templates/make-reservation.page.html b/templates/make-reservation.page.html index 16c0b56..ca388a2 100644 --- a/templates/make-reservation.page.html +++ b/templates/make-reservation.page.html @@ -10,14 +10,14 @@
Reservation Details
Room: {{$res.Room.RoomName}}
- Arrival: {{index .StringMap "start_date"}}
- Departure: {{index .StringMap "end_date"}}
+ Arrival: {{humanDate $res.StartDate}}
+ Departure: {{humanDate $res.EndDate}}