Skip to content

Commit

Permalink
add cli test for status.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonhadfield committed Aug 26, 2019
1 parent c72e286 commit a47a54b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/sn-dotfiles/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"time"

dotfilesSN "github.com/jonhadfield/dotfiles-sn"
"github.com/zalando/go-keyring"
keyring "github.com/zalando/go-keyring"

"github.com/jonhadfield/gosn"
"github.com/spf13/viper"
Expand Down
25 changes: 24 additions & 1 deletion cmd/sn-dotfiles/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,34 @@ func TestWipe(t *testing.T) {
_, _, _, _, _, _, err = sndotfiles.Add(session, home, []string{applePath}, true)
msg, disp, err := startCLI([]string{"sn-dotfiles", "wipe", "--force"})
assert.NoError(t, err)
assert.NotEmpty(t, msg)
assert.Contains(t, msg, "3 ")
assert.True(t, disp)
}

func TestStatus(t *testing.T) {
viper.SetEnvPrefix("sn")
assert.NoError(t, viper.BindEnv("email"))
assert.NoError(t, viper.BindEnv("password"))
assert.NoError(t, viper.BindEnv("server"))

home := getHome()
fwc := make(map[string]string)
applePath := fmt.Sprintf("%s/.fruit/apple", home)
fwc[applePath] = "apple content"
assert.NoError(t, createTemporaryFiles(fwc))
serverURL := os.Getenv("SN_SERVER")
if serverURL == "" {
serverURL = sndotfiles.SNServerURL
}
session, _, err := sndotfiles.GetSession(false, serverURL)
assert.NoError(t, err)
_, _, _, _, _, _, err = sndotfiles.Add(session, home, []string{applePath}, true)
msg, disp, err := startCLI([]string{"sn-dotfiles", "status", applePath})
assert.NoError(t, err)
assert.Contains(t, msg, ".fruit/apple identical")
assert.True(t, disp)
}

func TestAddSession(t *testing.T) {
viper.SetEnvPrefix("sn")
assert.NoError(t, viper.BindEnv("email"))
Expand Down

0 comments on commit a47a54b

Please sign in to comment.