| 179 | } |
| 180 | |
| 181 | func TestNoContent(t *testing.T) { |
| 182 | is := is.New(t) |
| 183 | ctx := context.Background() |
| 184 | dir := t.TempDir() |
| 185 | td := testdir.New(dir) |
| 186 | td.Files["controller/controller.go"] = ` |
| 187 | package controller |
| 188 | type Controller struct {} |
| 189 | func (c *Controller) Index() {} |
| 190 | func (c *Controller) Show(id string) {} |
| 191 | func (c *Controller) New() {} |
| 192 | func (c *Controller) Edit(id int) {} |
| 193 | ` |
| 194 | td.Files["controller/posts/comments/controller.go"] = ` |
| 195 | package comments |
| 196 | type Controller struct {} |
| 197 | func (c *Controller) Index(postId int) error { return nil } |
| 198 | func (c *Controller) Show(postId int, id string) error { return nil } |
| 199 | func (c *Controller) New(postId int) error { return nil } |
| 200 | func (c *Controller) Edit(postId int, id int) error { return nil } |
| 201 | ` |
| 202 | is.NoErr(td.Write(ctx)) |
| 203 | cli := testcli.New(dir) |
| 204 | app, err := cli.Start(ctx, "run") |
| 205 | is.NoErr(err) |
| 206 | defer app.Close() |
| 207 | // Root |
| 208 | res, err := app.Get("/") |
| 209 | is.NoErr(err) |
| 210 | is.NoErr(res.Diff(` |
| 211 | HTTP/1.1 204 No Content |
| 212 | `)) |
| 213 | res, err = app.Get("/10") |
| 214 | is.NoErr(err) |
| 215 | is.NoErr(res.Diff(` |
| 216 | HTTP/1.1 204 No Content |
| 217 | `)) |
| 218 | res, err = app.Get("/new") |
| 219 | is.NoErr(err) |
| 220 | is.NoErr(res.Diff(` |
| 221 | HTTP/1.1 204 No Content |
| 222 | `)) |
| 223 | res, err = app.Get("/10/edit") |
| 224 | is.NoErr(err) |
| 225 | is.NoErr(res.Diff(` |
| 226 | HTTP/1.1 204 No Content |
| 227 | `)) |
| 228 | res, err = app.GetJSON("/") |
| 229 | is.NoErr(err) |
| 230 | is.NoErr(res.Diff(` |
| 231 | HTTP/1.1 204 No Content |
| 232 | `)) |
| 233 | res, err = app.GetJSON("/10") |
| 234 | is.NoErr(err) |
| 235 | is.NoErr(res.Diff(` |
| 236 | HTTP/1.1 204 No Content |
| 237 | `)) |
| 238 | res, err = app.GetJSON("/new") |