You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dotctl/test/init_test.go

35 lines
605 B
Go

package test
import (
"bytes"
"path/filepath"
"testing"
"github.com/Marcusk19/bender/cmd"
"github.com/spf13/afero"
"github.com/spf13/viper"
)
func TestInitCommand(t *testing.T) {
viper.Set("testing", true)
fs := cmd.FileSystem
bender := cmd.RootCmd
actual := new(bytes.Buffer)
bender.SetOut(actual)
bender.SetErr(actual)
bender.SetArgs([]string{"init", "--dotfile-path=bender_test/dotfiles"})
bender.Execute()
homedir := "bender_test/"
_, err := afero.ReadFile(fs, filepath.Join(homedir, "dotfiles/bender/config"))
if err != nil {
t.Error(err.Error())
}
}