(t *testing.T, parentPath string)
| 69 | } |
| 70 | |
| 71 | func (c *dirWalkerWalkTestCase) setupPaths(t *testing.T, parentPath string) error { |
| 72 | c.parentPath = parentPath |
| 73 | |
| 74 | if parentPath != "" { |
| 75 | if err := os.MkdirAll(parentPath, 0755); err != nil { |
| 76 | return fmt.Errorf("unable to create path: %w", err) |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | if c.existsPath != "" { |
| 81 | c.existsPath = c.prependParentPath(c.existsPath) |
| 82 | if err := os.MkdirAll(c.existsPath, 0755); err != nil { |
| 83 | return fmt.Errorf("unable to create path: %w", err) |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | if c.existsFile != "" { |
| 88 | c.existsFile = c.prependParentPath(c.existsFile) |
| 89 | f, err := os.Create(c.existsFile) |
| 90 | if err != nil { |
| 91 | return fmt.Errorf("unable to create file: %w", err) |
| 92 | } |
| 93 | f.Close() |
| 94 | } |
| 95 | |
| 96 | if c.existsLink != "" { |
| 97 | c.existsLink = c.prependParentPath(c.existsLink) |
| 98 | if err := os.Symlink(t.TempDir(), c.existsLink); err != nil { |
| 99 | return fmt.Errorf("unable to create symbolic link: %w", err) |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | c.expectedParentPath = c.prependParentPath(c.expectedParentPath) |
| 104 | |
| 105 | return nil |
| 106 | } |
| 107 | |
| 108 | func (c *dirWalkerWalkTestCase) Assert(t *testing.T) { |
| 109 | c.walker.parentPath = c.parentPath |
no test coverage detected