9 . "github.com/onsi/ginkgo"
10 . "github.com/onsi/ginkgo/extensions/table"
11 . "github.com/onsi/gomega"
14var _ = Describe("Static Response Suite", func() {
15 const authenticated = "Authenticated"
19 // Generate a random id before each test to check the GAP-Upstream-Address
20 // is being set correctly
21 idBytes := make([]byte, 16)
22 _, err := io.ReadFull(rand.Reader, idBytes)
23 Expect(err).ToNot(HaveOccurred())
27 type serveHTTPTableInput struct {
34 DescribeTable("staticResponse ServeHTTP",
35 func(in *serveHTTPTableInput) {
37 if in.staticCode != 0 {
40 handler := newStaticResponseHandler(id, code)
42 req := httptest.NewRequest("", in.requestPath, nil)
43 rw := httptest.NewRecorder()
44 handler.ServeHTTP(rw, req)
46 Expect(rw.Header().Get("GAP-Upstream-Address")).To(Equal(id))
47 Expect(rw.Code).To(Equal(in.expectedCode))
48 Expect(rw.Body.String()).To(Equal(in.expectedBody))
50 Entry("with no given code", &serveHTTPTableInput{
52 staticCode: 0, // Placeholder for nil
53 expectedBody: authenticated,
54 expectedCode: http.StatusOK,
56 Entry("with status OK", &serveHTTPTableInput{
58 staticCode: http.StatusOK,
59 expectedBody: authenticated,
60 expectedCode: http.StatusOK,
62 Entry("with status NoContent", &serveHTTPTableInput{
64 staticCode: http.StatusNoContent,
65 expectedBody: authenticated,
66 expectedCode: http.StatusNoContent,
68 Entry("with status NotFound", &serveHTTPTableInput{
70 staticCode: http.StatusNotFound,
71 expectedBody: authenticated,
72 expectedCode: http.StatusNotFound,
74 Entry("with status Teapot", &serveHTTPTableInput{
76 staticCode: http.StatusTeapot,
77 expectedBody: authenticated,
78 expectedCode: http.StatusTeapot,
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list