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

Function createTestDir

tools/osutils/dir_test.go:79–142  ·  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

77// note: make sure to call os.RemoveAll(dir) after you are done
78// working with the created test dir.
79func createTestDir(t *testing.T) string {
80 dir, err := os.MkdirTemp(os.TempDir(), "test_dir")
81 if err != nil {
82 t.Fatal(err)
83 }
84
85 // create sub directories
86 if err := os.MkdirAll(filepath.Join(dir, "a"), os.ModePerm); err != nil {
87 t.Fatal(err)
88 }
89 if err := os.MkdirAll(filepath.Join(dir, "b"), os.ModePerm); err != nil {
90 t.Fatal(err)
91 }
92
93 {
94 f, err := os.OpenFile(filepath.Join(dir, "test1"), os.O_WRONLY|os.O_CREATE, 0644)
95 if err != nil {
96 t.Fatal(err)
97 }
98 f.Close()
99 }
100
101 {
102 f, err := os.OpenFile(filepath.Join(dir, "test2"), os.O_WRONLY|os.O_CREATE, 0644)
103 if err != nil {
104 t.Fatal(err)
105 }
106 f.Close()
107 }
108
109 {
110 f, err := os.OpenFile(filepath.Join(dir, "a/a1"), os.O_WRONLY|os.O_CREATE, 0644)
111 if err != nil {
112 t.Fatal(err)
113 }
114 f.Close()
115 }
116
117 {
118 f, err := os.OpenFile(filepath.Join(dir, "a/a2"), os.O_WRONLY|os.O_CREATE, 0644)
119 if err != nil {
120 t.Fatal(err)
121 }
122 f.Close()
123 }
124
125 {
126 f, err := os.OpenFile(filepath.Join(dir, "b/b2"), os.O_WRONLY|os.O_CREATE, 0644)
127 if err != nil {
128 t.Fatal(err)
129 }
130 f.Close()
131 }
132
133 {
134 f, err := os.OpenFile(filepath.Join(dir, "b/b2"), os.O_WRONLY|os.O_CREATE, 0644)
135 if err != nil {
136 t.Fatal(err)

Callers 1

TestMoveDirContentFunction · 0.70

Calls 1

CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…