note: make sure to call os.RemoveAll(dir) after you are done working with the created test dir.
(t *testing.T)
| 277 | // note: make sure to call os.RemoveAll(dir) after you are done |
| 278 | // working with the created test dir. |
| 279 | func 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 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…