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

Function TestEmptyActionWithView

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

Source from the content-addressed store, hash-verified

1753}
1754
1755func TestEmptyActionWithView(t *testing.T) {
1756 is := is.New(t)
1757 ctx := context.Background()
1758 dir := t.TempDir()
1759 td := testdir.New(dir)
1760 td.NodeModules["svelte"] = versions.Svelte
1761 td.Files["controller/controller.go"] = `
1762 package controller
1763 type Controller struct {}
1764 func (c *Controller) Index() {}
1765 `
1766 td.Files["view/index.svelte"] = `<h1>hello</h1>`
1767 is.NoErr(td.Write(ctx))
1768 cli := testcli.New(dir)
1769 app, err := cli.Start(ctx, "run")
1770 is.NoErr(err)
1771 defer app.Close()
1772 res, err := app.Get("/")
1773 is.NoErr(err)
1774 // HTML response
1775 is.NoErr(res.DiffHeaders(`
1776 HTTP/1.1 200 OK
1777 Transfer-Encoding: chunked
1778 Content-Type: text/html
1779 `))
1780 is.In(res.Body().String(), `<h1>hello</h1>`)
1781 is.NoErr(app.Close())
1782}
1783
1784func TestCustomActions(t *testing.T) {
1785 is := is.New(t)

Callers

nothing calls this directly

Calls 12

NewFunction · 0.92
NewFunction · 0.92
NewFunction · 0.92
NoErrMethod · 0.80
DiffHeadersMethod · 0.80
InMethod · 0.80
BodyMethod · 0.80
CloseMethod · 0.65
GetMethod · 0.65
StringMethod · 0.65
WriteMethod · 0.45
StartMethod · 0.45

Tested by

no test coverage detected