MCPcopy
hub / github.com/livebud/bud / TestJSONMultipleActions

Function TestJSONMultipleActions

framework/controller/controller_test.go:785–823  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

783}
784
785func 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
825func TestJSONUpdate500(t *testing.T) {
826 is := is.New(t)

Callers

nothing calls this directly

Calls 9

NewFunction · 0.92
NewFunction · 0.92
NewFunction · 0.92
NoErrMethod · 0.80
GetJSONMethod · 0.80
DiffMethod · 0.80
CloseMethod · 0.65
WriteMethod · 0.45
StartMethod · 0.45

Tested by

no test coverage detected