Skip to content

Commit

Permalink
root_test: Fix test errors
Browse files Browse the repository at this point in the history
Copying the config file sometimes fails with

"rename /builds/go/src/github.com/zaquestion/lab/testdata--8119903081016337361/lab.toml /home/root
/.config/lab/lab.toml: no such file or directory"

because there is a new-line character in the output of 'whoami'.  After
applying a fix to remove the new-line character I also occasionally see
issues with the patch for /home/root/.config/lab not existing.

Remove new line characters in the ConfigFile() return string, and make
sure the path for the file exists.

Signed-off-by: Prarit Bhargava <[email protected]>
  • Loading branch information
prarit committed May 4, 2021
1 parent 4a94ee9 commit d6c53cf
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,13 @@ func whoAmI() string {
}

func configFile() string {
return "/home/" + whoAmI() + "/.config/lab/lab.toml"
str := "/home/" + whoAmI() + "/.config/lab"
str = strings.Replace(str, "\n", "", -1)
if _, err := os.Stat(str); os.IsNotExist(err) {
os.MkdirAll(str, os.ModePerm)
}
str = str + "/lab.toml"
return str
}

// getAppOutput splits and truncates the list of strings returned from the "lab"
Expand Down

0 comments on commit d6c53cf

Please sign in to comment.