@@ -2111,30 +2111,27 @@ func createFileInPath(t *testing.T, path, filename, content string) (pathToFile
21112111}
21122112
21132113func createExecutableFileInPath (t * testing.T , path , filename , content string ) (pathToFile string ) {
2114- contentAsBytes := []byte (content )
2114+ ensureDirectoryExists (t , path )
2115+
21152116 pathToFile = path + "/" + filename
2116- err1 := os .MkdirAll (path , 0755 )
2117- if err1 != nil {
2118- failWithFailure (t , "creating folder " + path , "error" )
2119- }
2120- err2 := os .WriteFile (pathToFile , contentAsBytes , 0755 )
2121- if err2 != nil {
2117+ contentAsBytes := []byte (content )
2118+ err := os .WriteFile (pathToFile , contentAsBytes , 0755 )
2119+ if err != nil {
21222120 failWithFailure (t , "creating file " + filename + " with content " + content , "error" )
21232121 }
21242122 return
21252123}
21262124
2127- func createDirectory (t * testing.T , directory string ) (pathToFile string ) {
2128- return createDirectoryInPath (t , workingDir , directory )
2125+ func createDirectory (t * testing.T , directory string ) (pathToDirectory string ) {
2126+ return ensureDirectoryExists (t , workingDir + "/" + directory )
21292127}
21302128
2131- func createDirectoryInPath (t * testing.T , path , directory string ) (pathToFile string ) {
2132- pathToFile = path + "/" + directory
2133- err := os .Mkdir (pathToFile , 0755 )
2129+ func ensureDirectoryExists (t * testing.T , path string ) (pathToDirectory string ) {
2130+ err := os .MkdirAll (path , 0755 )
21342131 if err != nil {
2135- failWithFailure (t , "creating directory " + pathToFile , "error" )
2132+ failWithFailure (t , "creating folder " + path , "error" )
21362133 }
2137- return
2134+ return path
21382135}
21392136
21402137func removeFile (t * testing.T , path string ) {
0 commit comments