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

Function TestEmbedFavicon

framework/public/public_test.go:156–185  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

154}
155
156func TestEmbedFavicon(t *testing.T) {
157 is := is.New(t)
158 ctx := context.Background()
159 dir := t.TempDir()
160 td := testdir.New(dir)
161 td.BFiles["public/favicon.ico"] = favicon
162 is.NoErr(td.Write(ctx))
163 cli := testcli.New(dir)
164 app, err := cli.Start(ctx, "run", "--embed", "--hot=false")
165 is.NoErr(err)
166 defer app.Close()
167 res, err := app.Get("/favicon.ico")
168 is.NoErr(err)
169 is.Equal(200, res.Status())
170 is.Equal(res.Body().Bytes(), favicon)
171 // Replace favicon
172 favicon2 := []byte{0x00, 0x00, 0x01}
173 td.BFiles["public/favicon.ico"] = favicon2
174 is.NoErr(td.Write(ctx))
175 readyCtx, cancel := context.WithTimeout(ctx, 60*time.Second)
176 is.NoErr(app.Ready(readyCtx))
177 cancel()
178 // Favicon shouldn't have changed because non-Go files don't trigger
179 // full rebuilds and server restarts
180 res, err = app.Get("/favicon.ico")
181 is.NoErr(err)
182 is.Equal(200, res.Status())
183 is.Equal(res.Body().Bytes(), favicon)
184 is.NoErr(app.Close())
185}

Callers

nothing calls this directly

Calls 12

NewFunction · 0.92
NewFunction · 0.92
NewFunction · 0.92
NoErrMethod · 0.80
EqualMethod · 0.80
StatusMethod · 0.80
BodyMethod · 0.80
ReadyMethod · 0.80
CloseMethod · 0.65
GetMethod · 0.65
WriteMethod · 0.45
StartMethod · 0.45

Tested by

no test coverage detected