| 1782 | } |
| 1783 | |
| 1784 | func TestCustomActions(t *testing.T) { |
| 1785 | is := is.New(t) |
| 1786 | ctx := context.Background() |
| 1787 | dir := t.TempDir() |
| 1788 | td := testdir.New(dir) |
| 1789 | td.Files["controller/controller.go"] = ` |
| 1790 | package controller |
| 1791 | type Controller struct {} |
| 1792 | func (c *Controller) About() string { return "about" } |
| 1793 | ` |
| 1794 | td.Files["controller/users/users.go"] = ` |
| 1795 | package users |
| 1796 | type Controller struct {} |
| 1797 | func (c *Controller) Deactivate() string { return "deactivate" } |
| 1798 | ` |
| 1799 | is.NoErr(td.Write(ctx)) |
| 1800 | cli := testcli.New(dir) |
| 1801 | app, err := cli.Start(ctx, "run") |
| 1802 | is.NoErr(err) |
| 1803 | defer app.Close() |
| 1804 | res, err := app.Get("/about") |
| 1805 | is.NoErr(err) |
| 1806 | // HTML response |
| 1807 | is.NoErr(res.DiffHeaders(` |
| 1808 | HTTP/1.1 200 OK |
| 1809 | Content-Type: text/html |
| 1810 | `)) |
| 1811 | is.In(res.Body().String(), `about`) |
| 1812 | res, err = app.Get("/users/deactivate") |
| 1813 | is.NoErr(err) |
| 1814 | // HTML response |
| 1815 | is.NoErr(res.DiffHeaders(` |
| 1816 | HTTP/1.1 200 OK |
| 1817 | Content-Type: text/html |
| 1818 | `)) |
| 1819 | is.In(res.Body().String(), `deactivate`) |
| 1820 | is.NoErr(app.Close()) |
| 1821 | } |
| 1822 | |
| 1823 | func TestHandlerFuncs(t *testing.T) { |
| 1824 | is := is.New(t) |