mirror of https://github.com/Marcusk19/dotctl
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.
36 lines
575 B
Go
36 lines
575 B
Go
package test
|
|
|
|
import (
|
|
"bytes"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/Marcusk19/dotctl/cmd"
|
|
"github.com/spf13/afero"
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
func TestInitCommand(t *testing.T) {
|
|
viper.Set("testing", true)
|
|
|
|
fs := cmd.FileSystem
|
|
|
|
dotctl := cmd.RootCmd
|
|
actual := new(bytes.Buffer)
|
|
|
|
dotctl.SetOut(actual)
|
|
dotctl.SetErr(actual)
|
|
dotctl.SetArgs([]string{"init"})
|
|
|
|
dotctl.Execute()
|
|
|
|
homedir := os.Getenv("HOME")
|
|
|
|
_, err := afero.ReadFile(fs, filepath.Join(homedir, "dotfiles/dotctl/config"))
|
|
if err != nil {
|
|
t.Error(err.Error())
|
|
}
|
|
|
|
}
|