diff options
author | Anthony HAMON <anthony.hamon@iadvize.com> | 2018-08-28 20:24:19 +0200 |
---|---|---|
committer | Anthony HAMON <hamon.anth@gmail.com> | 2018-08-29 12:03:32 +0200 |
commit | 45fa2571287ac45045b9d6127dc0a38538b4fa4f (patch) | |
tree | e995c8c0769d44428f802d07a9f018914da41617 /pkg | |
parent | 99840d8fc4e4e877f80280272f29394a28699190 (diff) |
add test for StashSave and refactor StashSave method
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/commands/git.go | 2 | ||||
-rw-r--r-- | pkg/commands/git_test.go | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/pkg/commands/git.go b/pkg/commands/git.go index 9b3c72fd9..5a4d910d3 100644 --- a/pkg/commands/git.go +++ b/pkg/commands/git.go @@ -112,7 +112,7 @@ func (c *GitCommand) StashDo(index int, method string) error { // StashSave save stash // TODO: before calling this, check if there is anything to save func (c *GitCommand) StashSave(message string) error { - return c.OSCommand.RunCommand("git stash save " + c.OSCommand.Quote(message)) + return c.OSCommand.RunCommand(fmt.Sprintf("git stash save %s", c.OSCommand.Quote(message))) } // MergeStatusFiles merge status files diff --git a/pkg/commands/git_test.go b/pkg/commands/git_test.go index 554ffbd1a..920f527a8 100644 --- a/pkg/commands/git_test.go +++ b/pkg/commands/git_test.go @@ -173,6 +173,18 @@ func TestGitCommandStashDo(t *testing.T) { assert.NoError(t, gitCmd.StashDo(1, "drop")) } +func TestGitCommandStashSave(t *testing.T) { + gitCmd := newDummyGitCommand() + gitCmd.OSCommand.command = func(cmd string, args ...string) *exec.Cmd { + assert.EqualValues(t, "git", cmd) + assert.EqualValues(t, []string{"stash", "save", "A stash message"}, args) + + return exec.Command("echo") + } + + assert.NoError(t, gitCmd.StashSave("A stash message")) +} + func TestGitCommandDiff(t *testing.T) { gitCommand := newDummyGitCommand() assert.NoError(t, test.GenerateRepo("lots_of_diffs.sh")) |