MCPcopy
hub / github.com/git-lfs/git-lfs / setupPaths

Method setupPaths

tools/dir_walker_test.go:71–106  ·  view source on GitHub ↗
(t *testing.T, parentPath string)

Source from the content-addressed store, hash-verified

69}
70
71func (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
108func (c *dirWalkerWalkTestCase) Assert(t *testing.T) {
109 c.walker.parentPath = c.parentPath

Callers 1

TestDirWalkerWalkFunction · 0.80

Calls 4

prependParentPathMethod · 0.95
ErrorfMethod · 0.65
CloseMethod · 0.65
TempDirMethod · 0.45

Tested by

no test coverage detected