update test for link

pull/25/head
Marcus Kok 2 years ago
parent 5473a2cf9b
commit ecbf9d6988

@ -14,8 +14,16 @@ import (
func TestLinkCommand(t *testing.T) {
oldDotfilePath := viper.GetString("dotfile-path")
setUpTesting()
viper.Set("testing", true)
fs := cmd.FileSystem
homedir := os.Getenv("HOME")
fs.MkdirAll(filepath.Join(homedir, "dotfiles/dotctl"), 0755)
links := map[string]string {
"someconfig": filepath.Join(homedir, ".config/someconfig"),
}
viper.Set("links", links)
dotctl := cmd.RootCmd
actual := new(bytes.Buffer)
@ -25,7 +33,6 @@ func TestLinkCommand(t *testing.T) {
dotctl.Execute()
homedir := os.Getenv("HOME")
someconfig := filepath.Join(homedir, ".config/someconfig/")
somedot := filepath.Join(homedir, "dotfiles/someconfig/")
@ -33,24 +40,5 @@ func TestLinkCommand(t *testing.T) {
assert.Equal(t, expected, actual.String(), "actual differs from expected")
tearDownTesting(oldDotfilePath)
}
func setUpTesting() {
viper.Set("testing", true)
fs := cmd.FileSystem
homedir := os.Getenv("HOME")
fakeLinks := map[string]string {"someconfig": filepath.Join(homedir, ".config/someconfig")}
viper.Set("links", fakeLinks)
fs.MkdirAll(filepath.Join(homedir, "dotfiles/dotctl"), 0755)
fs.Create(filepath.Join(homedir, "dotfiles/dotctl/config"))
viper.Set("dotfile-path", filepath.Join(homedir, "dotfiles"))
viper.Set("someconfig", filepath.Join(homedir, ".config/someconfig/"))
}
func tearDownTesting(oldDotfilePath string) {
viper.Set("dotfile-path", oldDotfilePath)
viper.WriteConfig()
}

Loading…
Cancel
Save