Loading controllers/themes/themes_test.go 0 → 100644 +39 −0 Original line number Diff line number Diff line package themes import ( "net/http" "testing" "github.com/taironas/route" tgTesting "github.com/taironas/tinygraphs/testing" ) func TestTheme(t *testing.T) { r := new(route.Router) r.HandleFunc("/themes", Theme) r.HandleFunc("/themes/:key", Theme) test := tgTesting.GenerateHandlerFunc(t, Theme) for _, p := range tgTesting.GoodParams { recorder := test("/themes", "GET", p, r) if recorder.Code != http.StatusOK { t.Errorf("returned %v. Expected %v.", recorder.Code, http.StatusOK) } recorder = test("/themes/somekey", "GET", p, r) if recorder.Code != http.StatusOK { t.Errorf("returned %v. Expected %v.", recorder.Code, http.StatusOK) } } for _, p := range tgTesting.BadParams { recorder := test("/themes", "GET", p, r) if recorder.Code != http.StatusOK { t.Errorf("returned %v. Expected %v.", recorder.Code, http.StatusOK) } recorder = test("/themes/somekey", "GET", p, r) if recorder.Code != http.StatusOK { t.Errorf("returned %v. Expected %v.", recorder.Code, http.StatusOK) } } } Loading
controllers/themes/themes_test.go 0 → 100644 +39 −0 Original line number Diff line number Diff line package themes import ( "net/http" "testing" "github.com/taironas/route" tgTesting "github.com/taironas/tinygraphs/testing" ) func TestTheme(t *testing.T) { r := new(route.Router) r.HandleFunc("/themes", Theme) r.HandleFunc("/themes/:key", Theme) test := tgTesting.GenerateHandlerFunc(t, Theme) for _, p := range tgTesting.GoodParams { recorder := test("/themes", "GET", p, r) if recorder.Code != http.StatusOK { t.Errorf("returned %v. Expected %v.", recorder.Code, http.StatusOK) } recorder = test("/themes/somekey", "GET", p, r) if recorder.Code != http.StatusOK { t.Errorf("returned %v. Expected %v.", recorder.Code, http.StatusOK) } } for _, p := range tgTesting.BadParams { recorder := test("/themes", "GET", p, r) if recorder.Code != http.StatusOK { t.Errorf("returned %v. Expected %v.", recorder.Code, http.StatusOK) } recorder = test("/themes/somekey", "GET", p, r) if recorder.Code != http.StatusOK { t.Errorf("returned %v. Expected %v.", recorder.Code, http.StatusOK) } } }