|
|
|
@ -14,8 +14,16 @@ import (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func TestLinkCommand(t *testing.T) {
|
|
|
|
func TestLinkCommand(t *testing.T) {
|
|
|
|
oldDotfilePath := viper.GetString("dotfile-path")
|
|
|
|
viper.Set("testing", true)
|
|
|
|
setUpTesting()
|
|
|
|
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
|
|
|
|
dotctl := cmd.RootCmd
|
|
|
|
actual := new(bytes.Buffer)
|
|
|
|
actual := new(bytes.Buffer)
|
|
|
|
|
|
|
|
|
|
|
|
@ -25,7 +33,6 @@ func TestLinkCommand(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
|
|
dotctl.Execute()
|
|
|
|
dotctl.Execute()
|
|
|
|
|
|
|
|
|
|
|
|
homedir := os.Getenv("HOME")
|
|
|
|
|
|
|
|
someconfig := filepath.Join(homedir, ".config/someconfig/")
|
|
|
|
someconfig := filepath.Join(homedir, ".config/someconfig/")
|
|
|
|
somedot := filepath.Join(homedir, "dotfiles/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")
|
|
|
|
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()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|