Loading controllers/squares/banner_test.go +21 −0 Original line number Diff line number Diff line Loading @@ -28,3 +28,24 @@ func TestBannerRandom(t *testing.T) { } } } func TestBannerRandomGradient(t *testing.T) { r := new(route.Router) r.HandleFunc("/squares/banner/random", BannerRandomGradient) test := tgTesting.GenerateHandlerFunc(t, BannerRandomGradient) for _, p := range tgTesting.GoodParams { recorder := test("/squares/banner/random", "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("/squares/banner/random", "GET", p, r) if recorder.Code != http.StatusOK { t.Errorf("returned %v. Expected %v.", recorder.Code, http.StatusOK) } } } testing/testing.go +4 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ func init() { `{"size":"200"}`, `{"bg":"ff4008","fg":"04d6f2"}`, `{"theme":"frogideas"}`, `{"w":"500", "h":"100"}`, `{"xs":"500"}`, } BadParams = []string{ Loading @@ -27,6 +29,8 @@ func init() { `{"size":"wrongType"}`, `{"bg":"wrongType","fg":"wrongType"}`, `{"theme":"wrongTheme"}`, `{"w":"wrongW", "h":"wrongH"}`, `{"xs":"wrongXS"}`, } } Loading Loading
controllers/squares/banner_test.go +21 −0 Original line number Diff line number Diff line Loading @@ -28,3 +28,24 @@ func TestBannerRandom(t *testing.T) { } } } func TestBannerRandomGradient(t *testing.T) { r := new(route.Router) r.HandleFunc("/squares/banner/random", BannerRandomGradient) test := tgTesting.GenerateHandlerFunc(t, BannerRandomGradient) for _, p := range tgTesting.GoodParams { recorder := test("/squares/banner/random", "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("/squares/banner/random", "GET", p, r) if recorder.Code != http.StatusOK { t.Errorf("returned %v. Expected %v.", recorder.Code, http.StatusOK) } } }
testing/testing.go +4 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ func init() { `{"size":"200"}`, `{"bg":"ff4008","fg":"04d6f2"}`, `{"theme":"frogideas"}`, `{"w":"500", "h":"100"}`, `{"xs":"500"}`, } BadParams = []string{ Loading @@ -27,6 +29,8 @@ func init() { `{"size":"wrongType"}`, `{"bg":"wrongType","fg":"wrongType"}`, `{"theme":"wrongTheme"}`, `{"w":"wrongW", "h":"wrongH"}`, `{"xs":"wrongXS"}`, } } Loading