(t *testing.T)
| 152 | } |
| 153 | |
| 154 | func TestTreeMoar(t *testing.T) { |
| 155 | hStub := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) |
| 156 | hStub1 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) |
| 157 | hStub2 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) |
| 158 | hStub3 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) |
| 159 | hStub4 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) |
| 160 | hStub5 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) |
| 161 | hStub6 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) |
| 162 | hStub7 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) |
| 163 | hStub8 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) |
| 164 | hStub9 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) |
| 165 | hStub10 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) |
| 166 | hStub11 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) |
| 167 | hStub12 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) |
| 168 | hStub13 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) |
| 169 | hStub14 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) |
| 170 | hStub15 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) |
| 171 | hStub16 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) |
| 172 | |
| 173 | // TODO: panic if we see {id}{x} because we're missing a delimiter, its not possible. |
| 174 | // also {:id}* is not possible. |
| 175 | |
| 176 | tr := &node{} |
| 177 | |
| 178 | tr.InsertRoute(mGET, "/articlefun", hStub5) |
| 179 | tr.InsertRoute(mGET, "/articles/{id}", hStub) |
| 180 | tr.InsertRoute(mDELETE, "/articles/{slug}", hStub8) |
| 181 | tr.InsertRoute(mGET, "/articles/search", hStub1) |
| 182 | tr.InsertRoute(mGET, "/articles/{id}:delete", hStub8) |
| 183 | tr.InsertRoute(mGET, "/articles/{iidd}!sup", hStub4) |
| 184 | tr.InsertRoute(mGET, "/articles/{id}:{op}", hStub3) |
| 185 | tr.InsertRoute(mGET, "/articles/{id}:{op}", hStub2) // this route sets a new handler for the above route |
| 186 | tr.InsertRoute(mGET, "/articles/{slug:^[a-z]+}/posts", hStub) // up to tail '/' will only match if contents match the rex |
| 187 | tr.InsertRoute(mGET, "/articles/{id}/posts/{pid}", hStub6) // /articles/123/posts/1 |
| 188 | tr.InsertRoute(mGET, "/articles/{id}/posts/{month}/{day}/{year}/{slug}", hStub7) // /articles/123/posts/09/04/1984/juice |
| 189 | tr.InsertRoute(mGET, "/articles/{id}.json", hStub10) |
| 190 | tr.InsertRoute(mGET, "/articles/{id}/data.json", hStub11) |
| 191 | tr.InsertRoute(mGET, "/articles/files/{file}.{ext}", hStub12) |
| 192 | tr.InsertRoute(mPUT, "/articles/me", hStub13) |
| 193 | |
| 194 | // TODO: make a separate test case for this one.. |
| 195 | // tr.InsertRoute(mGET, "/articles/{id}/{id}", hStub1) // panic expected, we're duplicating param keys |
| 196 | |
| 197 | tr.InsertRoute(mGET, "/pages/*", hStub) |
| 198 | tr.InsertRoute(mGET, "/pages/*", hStub9) |
| 199 | |
| 200 | tr.InsertRoute(mGET, "/users/{id}", hStub14) |
| 201 | tr.InsertRoute(mGET, "/users/{id}/settings/{key}", hStub15) |
| 202 | tr.InsertRoute(mGET, "/users/{id}/settings/*", hStub16) |
| 203 | |
| 204 | tests := []struct { |
| 205 | h http.Handler |
| 206 | r string |
| 207 | k []string |
| 208 | v []string |
| 209 | m methodTyp |
| 210 | }{ |
| 211 | {m: mGET, r: "/articles/search", h: hStub1, k: []string{}, v: []string{}}, |
nothing calls this directly
no test coverage detected