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

Function TestCreateRemovePublicGraceful

internal/cli/create_test.go:156–194  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

154}
155
156func TestCreateRemovePublicGraceful(t *testing.T) {
157 is := is.New(t)
158 ctx := context.Background()
159 dir := t.TempDir()
160 td := testdir.New(dir)
161 err := td.Write(ctx)
162 is.NoErr(err)
163 cli := testcli.New(dir)
164 is.NoErr(td.NotExists(".gitignore"))
165 result, err := cli.Run(ctx, "create", dir)
166 is.NoErr(err)
167 is.Equal(result.Stdout(), "")
168 is.In(result.Stderr(), "Ready")
169
170 // Start the app
171 app, err := cli.Start(ctx, "run")
172 is.NoErr(err)
173
174 // Test the favicon
175 res, err := app.Get("/favicon.ico")
176 is.NoErr(err)
177 is.Equal(res.Status(), 200)
178 is.NoErr(td.Exists("public/favicon.ico"))
179
180 // Remove the public directory
181 is.NoErr(os.RemoveAll(filepath.Join(dir, "public")))
182 is.NoErr(td.NotExists("bud/public"))
183
184 // Wait for the app to recover
185 readyCtx, cancel := context.WithTimeout(ctx, 15*time.Second)
186 is.NoErr(app.Ready(readyCtx))
187 cancel()
188
189 res, err = app.Get("/favicon.ico")
190 is.NoErr(err)
191 is.Equal(res.Status(), 404)
192
193 is.NoErr(app.Close())
194}
195
196func TestReleaseVersionOk(t *testing.T) {
197 if versions.Bud == "latest" {

Callers

nothing calls this directly

Calls 15

NewFunction · 0.92
NewFunction · 0.92
NewFunction · 0.92
NoErrMethod · 0.80
NotExistsMethod · 0.80
EqualMethod · 0.80
InMethod · 0.80
StatusMethod · 0.80
ExistsMethod · 0.80
ReadyMethod · 0.80
RunMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected