Fixing tests
This commit is contained in:
parent
29da5958f8
commit
43952efd77
2 changed files with 11 additions and 7 deletions
|
@ -377,8 +377,13 @@ func respondWithError(h *Handlers, w http.ResponseWriter, r *http.Request, err e
|
|||
|
||||
func (h *Handlers) Create(model interface{}) http.Handler {
|
||||
fn := func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.Method {
|
||||
case "GET":
|
||||
h.get(w, r, reflect.ModelNameLowerPlural(model), h.Config.CreatePattern())
|
||||
case "POST":
|
||||
h.post(w, r, reflect.ModelNameLowerPlural(model), h.Config.CreatePattern())
|
||||
}
|
||||
}
|
||||
|
||||
return http.HandlerFunc(fn)
|
||||
}
|
||||
|
|
|
@ -263,7 +263,7 @@ func (t *testSuite) TestReadContest() {
|
|||
}
|
||||
|
||||
func (t *testSuite) TestSchoolSubscriptionForm() {
|
||||
req, err := handlers.NewCreateRequest(&orm.School{}, "/create/", "html", "GET", nil)
|
||||
req, err := handlers.NewCreateRequest(&orm.School{}, "/schools/create/", "html", "GET", nil)
|
||||
t.Nil(err)
|
||||
|
||||
req, err = login(req, handlers, "subscriber", "subscribe")
|
||||
|
@ -272,7 +272,7 @@ func (t *testSuite) TestSchoolSubscriptionForm() {
|
|||
rr := httptest.NewRecorder()
|
||||
|
||||
router := mux.NewRouter()
|
||||
router.Handle("/schools/create", handlers.Create(&orm.School{}))
|
||||
router.Handle("/schools/create/", handlers.Create(&orm.School{}))
|
||||
router.ServeHTTP(rr, req)
|
||||
|
||||
t.Equal(http.StatusOK, rr.Code)
|
||||
|
@ -311,7 +311,7 @@ func (t *testSuite) TestSchoolSubscription() {
|
|||
form.Add("Code", "123")
|
||||
form.Add("Email", "foo@school.org")
|
||||
|
||||
req, err := handlers.NewCreateRequest(&orm.School{}, "/create/", "html", "POST", form)
|
||||
req, err := handlers.NewCreateRequest(&orm.School{}, "/schools/create/", "html", "POST", form)
|
||||
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
t.Nil(err)
|
||||
|
||||
|
@ -338,7 +338,6 @@ func (t *testSuite) TestSchoolSubscription() {
|
|||
}
|
||||
ok := true
|
||||
doc.Find("dd").Each(func(i int, s *goquery.Selection) {
|
||||
log.Print(s)
|
||||
t.Equal(expected[i], s.Text())
|
||||
if t.Failed() {
|
||||
ok = false
|
||||
|
@ -367,7 +366,7 @@ func (t *testSuite) TestSchoolSubscription() {
|
|||
form.Add("category_id", "1")
|
||||
form.Add("school_id", strconv.Itoa(int(school.ID)))
|
||||
|
||||
req, err := handlers.NewCreateRequest(&orm.Participant{}, "/create/", "html", "POST", form)
|
||||
req, err := handlers.NewCreateRequest(&orm.Participant{}, "/participants/create/", "html", "POST", form)
|
||||
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
t.Nil(err)
|
||||
|
||||
|
@ -377,7 +376,7 @@ func (t *testSuite) TestSchoolSubscription() {
|
|||
rr := httptest.NewRecorder()
|
||||
|
||||
router := mux.NewRouter()
|
||||
router.Handle("/create/", handlers.Create(&orm.Participant{}))
|
||||
router.Handle("/participants/create/", handlers.Create(&orm.Participant{}))
|
||||
router.ServeHTTP(rr, req)
|
||||
|
||||
t.Equal(http.StatusSeeOther, rr.Code)
|
||||
|
|
Loading…
Reference in a new issue