fixing all tests

pull/25/head
Marcus Kok 2 years ago
parent c4c504189c
commit 134c19cfc2

@ -55,6 +55,7 @@ func runInitCommand(cmd *cobra.Command, args []string) {
fs := FileSystem
// if user has passed a dotfile path flag need to add it to
// viper's search path for a config file
testing := viper.GetBool("testing")
viper.AddConfigPath(filepath.Join(DotfilePath, "dotctl"))
if(viper.Get("testing") == true && fs.Name() != "MemMapFS") {
@ -71,12 +72,12 @@ func runInitCommand(cmd *cobra.Command, args []string) {
panic(fmt.Errorf("Unable to create config file %w", err))
}
err = viper.WriteConfig()
if err != nil && viper.Get("testing") != true {
log.Fatalf("Unable to write config on init: %s\n", err)
}
if !testing {
err = viper.WriteConfig()
if err != nil && viper.Get("testing") != true {
log.Fatalf("Unable to write config on init: %s\n", err)
}
if (viper.Get("testing") != "true"){
_, err = git.PlainInit(DotfilePath, false)
if err != nil {
log.Fatal(err)

@ -2,6 +2,7 @@ package test
import (
"bytes"
"os"
"path/filepath"
"testing"
@ -20,11 +21,11 @@ func TestInitCommand(t *testing.T) {
dotctl.SetOut(actual)
dotctl.SetErr(actual)
dotctl.SetArgs([]string{"init", "--dotfile-path=dotctl_test/dotfiles"})
dotctl.SetArgs([]string{"init"})
dotctl.Execute()
homedir := "dotctl_test/"
homedir := os.Getenv("HOME")
_, err := afero.ReadFile(fs, filepath.Join(homedir, "dotfiles/dotctl/config"))
if err != nil {

@ -41,6 +41,5 @@ func TestLinkCommand(t *testing.T) {
expected := fmt.Sprintf("%s,%s", someconfig, somedot)
assert.Equal(t, expected, actual.String(), "actual differs from expected")
}

Loading…
Cancel
Save