Commit da1729c4 authored by santiaago's avatar santiaago
Browse files

add TestBannerRandomGradient #36

parent 0eaa48c7
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -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)
		}
	}
}
+4 −0
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ func init() {
		`{"size":"200"}`,
		`{"bg":"ff4008","fg":"04d6f2"}`,
		`{"theme":"frogideas"}`,
		`{"w":"500", "h":"100"}`,
		`{"xs":"500"}`,
	}

	BadParams = []string{
@@ -27,6 +29,8 @@ func init() {
		`{"size":"wrongType"}`,
		`{"bg":"wrongType","fg":"wrongType"}`,
		`{"theme":"wrongTheme"}`,
		`{"w":"wrongW", "h":"wrongH"}`,
		`{"xs":"wrongXS"}`,
	}
}