(t *testing.T)
| 72 | } |
| 73 | |
| 74 | func TestRouting(t *testing.T) { |
| 75 | app := newApp() |
| 76 | e := httptest.New(t, app) |
| 77 | |
| 78 | tests := []troute{ |
| 79 | // GET |
| 80 | newTroute("GET", "", "/healthcheck", httptest.StatusOK), |
| 81 | newTroute("GET", "", "/games/{gameID}/clans", httptest.StatusOK, "gameID", "42"), |
| 82 | newTroute("GET", "", "/games/{gameID}/clans/clan/{clanPublicID}", httptest.StatusOK, "gameID", "42", "clanPublicID", "93"), |
| 83 | newTroute("GET", "", "/games/{gameID}/clans/search", httptest.StatusOK, "gameID", "42"), |
| 84 | newTroute("GET", "", "/games/challenge", httptest.StatusOK), |
| 85 | newTroute("GET", "", "/games/challenge/beginner/start", httptest.StatusOK), |
| 86 | newTroute("GET", "", "/games/challenge/beginner/level/first", httptest.StatusOK), |
| 87 | newTroute("GET", "", "/games/challenge/intermediate", httptest.StatusOK), |
| 88 | newTroute("GET", "", "/games/challenge/intermediate/start", httptest.StatusOK), |
| 89 | newTroute("GET", "mysubdomain", "/", httptest.StatusOK), |
| 90 | newTroute("GET", "mywildcardsubdomain", "/", httptest.StatusOK), |
| 91 | newTroute("GET", "mywildcardsubdomain", "/party", httptest.StatusOK), |
| 92 | // PUT |
| 93 | newTroute("PUT", "", "/games/{gameID}/players/{clanPublicID}", httptest.StatusOK, "gameID", "42", "clanPublicID", "93"), |
| 94 | newTroute("PUT", "", "/games/{gameID}/clans/clan/{clanPublicID}", httptest.StatusOK, "gameID", "42", "clanPublicID", "93"), |
| 95 | // POST |
| 96 | newTroute("POST", "", "/games/{gameID}/clans", httptest.StatusOK, "gameID", "42"), |
| 97 | newTroute("POST", "", "/games/{gameID}/players", httptest.StatusOK, "gameID", "42"), |
| 98 | newTroute("POST", "", "/games/{gameID}/clans/{clanPublicID}/leave", httptest.StatusOK, "gameID", "42", "clanPublicID", "93"), |
| 99 | newTroute("POST", "", "/games/{gameID}/clans/{clanPublicID}/memberships/application", httptest.StatusOK, "gameID", "42", "clanPublicID", "93"), |
| 100 | newTroute("POST", "", "/games/{gameID}/clans/{clanPublicID}/memberships/application/{action}", httptest.StatusOK, "gameID", "42", "clanPublicID", "93", "action", "somethinghere"), |
| 101 | newTroute("POST", "", "/games/{gameID}/clans/{clanPublicID}/memberships/invitation", httptest.StatusOK, "gameID", "42", "clanPublicID", "93"), |
| 102 | newTroute("POST", "", "/games/{gameID}/clans/{clanPublicID}/memberships/invitation/{action}", httptest.StatusOK, "gameID", "42", "clanPublicID", "93", "action", "somethinghere"), |
| 103 | newTroute("POST", "", "/games/{gameID}/clans/{clanPublicID}/memberships/delete", httptest.StatusOK, "gameID", "42", "clanPublicID", "93"), |
| 104 | newTroute("POST", "", "/games/{gameID}/clans/{clanPublicID}/memberships/promote", httptest.StatusOK, "gameID", "42", "clanPublicID", "93"), |
| 105 | newTroute("POST", "", "/games/{gameID}/clans/{clanPublicID}/memberships/demote", httptest.StatusOK, "gameID", "42", "clanPublicID", "93"), |
| 106 | // POST: / will be tested alone |
| 107 | // custom not found |
| 108 | newTroute("GET", "", "/notfound", httptest.StatusNotFound), |
| 109 | newTroute("POST", "", "/notfound2", httptest.StatusNotFound), |
| 110 | newTroute("PUT", "", "/notfound3", httptest.StatusNotFound), |
| 111 | newTroute("GET", "mysubdomain", "/notfound42", httptest.StatusNotFound), |
| 112 | } |
| 113 | |
| 114 | for _, tt := range tests { |
| 115 | et := e.Request(tt.method, tt.path) |
| 116 | if tt.subdomain != "" { |
| 117 | et.WithURL("http://" + tt.subdomain + ".localhost:8080") |
| 118 | } |
| 119 | et.Expect().Status(tt.status).Body().IsEqual(tt.expectedBody) |
| 120 | } |
| 121 | |
| 122 | // test POST "/" limit data and post data return |
| 123 | |
| 124 | // test with small body |
| 125 | e.POST("/").WithBytes([]byte("ok")).Expect().Status(httptest.StatusOK).Body().IsEqual("ok") |
| 126 | // test with equal to max body size limit |
| 127 | bsent := make([]byte, maxBodySize, maxBodySize) |
| 128 | e.POST("/").WithBytes(bsent).Expect().Status(httptest.StatusOK).Body().Length().Equal(len(bsent)) |
| 129 | // test with larger body sent and wait for the custom response |
| 130 | largerBSent := make([]byte, maxBodySize+1, maxBodySize+1) |
| 131 | e.POST("/").WithBytes(largerBSent).Expect().Status(httptest.StatusBadRequest).Body().IsEqual("http: request body too large") |
nothing calls this directly
no test coverage detected
searching dependent graphs…