| 783 | } |
| 784 | |
| 785 | func TestJSONMultipleActions(t *testing.T) { |
| 786 | is := is.New(t) |
| 787 | ctx := context.Background() |
| 788 | dir := t.TempDir() |
| 789 | td := testdir.New(dir) |
| 790 | td.Files["controller/controller.go"] = ` |
| 791 | package controller |
| 792 | type Controller struct {} |
| 793 | func (c *Controller) Index() string { |
| 794 | return "hello world" |
| 795 | } |
| 796 | // Show route |
| 797 | func (c *Controller) Show(id int) int { |
| 798 | return id |
| 799 | } |
| 800 | ` |
| 801 | is.NoErr(td.Write(ctx)) |
| 802 | cli := testcli.New(dir) |
| 803 | app, err := cli.Start(ctx, "run") |
| 804 | is.NoErr(err) |
| 805 | defer app.Close() |
| 806 | res, err := app.GetJSON("/") |
| 807 | is.NoErr(err) |
| 808 | is.NoErr(res.Diff(` |
| 809 | HTTP/1.1 200 OK |
| 810 | Content-Type: application/json |
| 811 | |
| 812 | "hello world" |
| 813 | `)) |
| 814 | res, err = app.GetJSON("/10") |
| 815 | is.NoErr(err) |
| 816 | is.NoErr(res.Diff(` |
| 817 | HTTP/1.1 200 OK |
| 818 | Content-Type: application/json |
| 819 | |
| 820 | 10 |
| 821 | `)) |
| 822 | is.NoErr(app.Close()) |
| 823 | } |
| 824 | |
| 825 | func TestJSONUpdate500(t *testing.T) { |
| 826 | is := is.New(t) |