MCPcopy
hub / github.com/pocketbase/pocketbase / createTestDir

Function createTestDir

apis/base_test.go:279–313  ·  view source on GitHub ↗

note: make sure to call os.RemoveAll(dir) after you are done working with the created test dir.

(t *testing.T)

Source from the content-addressed store, hash-verified

277// note: make sure to call os.RemoveAll(dir) after you are done
278// working with the created test dir.
279func createTestDir(t *testing.T) string {
280 dir, err := os.MkdirTemp(os.TempDir(), "test_dir")
281 if err != nil {
282 t.Fatal(err)
283 }
284
285 if err := os.WriteFile(filepath.Join(dir, "index.html"), []byte("root index.html"), 0644); err != nil {
286 t.Fatal(err)
287 }
288 if err := os.WriteFile(filepath.Join(dir, "testroot"), []byte("root test"), 0644); err != nil {
289 t.Fatal(err)
290 }
291
292 if err := os.MkdirAll(filepath.Join(dir, "sub"), os.ModePerm); err != nil {
293 t.Fatal(err)
294 }
295 if err := os.WriteFile(filepath.Join(dir, "sub/index.html"), []byte("sub index.html"), 0644); err != nil {
296 t.Fatal(err)
297 }
298 if err := os.WriteFile(filepath.Join(dir, "sub/test"), []byte("sub test"), 0644); err != nil {
299 t.Fatal(err)
300 }
301
302 if err := os.MkdirAll(filepath.Join(dir, "sub", "sub2"), os.ModePerm); err != nil {
303 t.Fatal(err)
304 }
305 if err := os.WriteFile(filepath.Join(dir, "sub/sub2/index.html"), []byte("sub2 index.html"), 0644); err != nil {
306 t.Fatal(err)
307 }
308 if err := os.WriteFile(filepath.Join(dir, "sub/sub2/test"), []byte("sub2 test"), 0644); err != nil {
309 t.Fatal(err)
310 }
311
312 return dir
313}

Callers 2

TestStaticFunction · 0.70
TestMustSubFSFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…