MCPcopy Create free account
hub / github.com/flant/shell-operator / prepareTestDirTree

Function prepareTestDirTree

pkg/utils/file/file_test.go:16–48  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

14)
15
16func prepareTestDirTree() (string, error) {
17 tmpDir, err := os.MkdirTemp("", "")
18 if err != nil {
19 return "", fmt.Errorf("error creating temp directory: %v\n", err)
20 }
21
22 if err = os.MkdirAll(filepath.Join(tmpDir, "aa"), 0o755); err != nil {
23 os.RemoveAll(tmpDir)
24 return "", err
25 }
26
27 if err = os.MkdirAll(filepath.Join(tmpDir, "lib"), 0o755); err != nil {
28 os.RemoveAll(tmpDir)
29 return "", err
30 }
31
32 if err = createExecutableFile(filepath.Join(tmpDir, "aa/exec.py")); err != nil {
33 os.RemoveAll(tmpDir)
34 return "", err
35 }
36
37 if err = createExecutableFile(filepath.Join(tmpDir, "check.py")); err != nil {
38 os.RemoveAll(tmpDir)
39 return "", err
40 }
41
42 if err = createExecutableFile(filepath.Join(filepath.Join(tmpDir, "lib"), "lib.py")); err != nil {
43 os.RemoveAll(tmpDir)
44 return "", err
45 }
46
47 return tmpDir, nil
48}
49
50func createExecutableFile(file string) error {
51 if _, err := os.Create(file); err != nil {

Callers 2

Calls 1

createExecutableFileFunction · 0.85

Tested by

no test coverage detected