summaryrefslogtreecommitdiffstats
path: root/pkg/commands/git_commands/stash_test.go
diff options
context:
space:
mode:
authorRyooooooga <eial5q265e5@gmail.com>2022-10-15 11:15:31 +0900
committerRyooooooga <eial5q265e5@gmail.com>2022-10-16 09:12:43 +0900
commiteceb3a5aa6de864f31c52016e6fd497b9b6a1214 (patch)
treea2240f25bf60b1d4277ee85e9c5603f05a3ed6aa /pkg/commands/git_commands/stash_test.go
parent8a9eefa4d275f925e149be2c05c5c6958da86f5b (diff)
chore: refactor rename stash
Diffstat (limited to 'pkg/commands/git_commands/stash_test.go')
-rw-r--r--pkg/commands/git_commands/stash_test.go43
1 files changed, 43 insertions, 0 deletions
diff --git a/pkg/commands/git_commands/stash_test.go b/pkg/commands/git_commands/stash_test.go
index e5ce39181..41efc07db 100644
--- a/pkg/commands/git_commands/stash_test.go
+++ b/pkg/commands/git_commands/stash_test.go
@@ -123,3 +123,46 @@ func TestStashStashEntryCmdObj(t *testing.T) {
})
}
}
+
+func TestStashRename(t *testing.T) {
+ type scenario struct {
+ testName string
+ index int
+ message string
+ expectedDropCmd []string
+ dropResult string
+ expectedStoreCmd []string
+ }
+
+ scenarios := []scenario{
+ {
+ testName: "Default case",
+ index: 3,
+ message: "New message",
+ expectedDropCmd: []string{"stash", "drop", "stash@{3}"},
+ dropResult: "Dropped refs/stash@{3} (f0d0f20f2f61ffd6d6bfe0752deffa38845a3edd)\n",
+ expectedStoreCmd: []string{"stash", "store", "f0d0f20f2f61ffd6d6bfe0752deffa38845a3edd", "-m", "New message"},
+ },
+ {
+ testName: "Empty message",
+ index: 4,
+ message: "",
+ expectedDropCmd: []string{"stash", "drop", "stash@{4}"},
+ dropResult: "Dropped refs/stash@{4} (f0d0f20f2f61ffd6d6bfe0752deffa38845a3edd)\n",
+ expectedStoreCmd: []string{"stash", "store", "f0d0f20f2f61ffd6d6bfe0752deffa38845a3edd"},
+ },
+ }
+
+ for _, s := range scenarios {
+ s := s
+ t.Run(s.testName, func(t *testing.T) {
+ runner := oscommands.NewFakeRunner(t).
+ ExpectGitArgs(s.expectedDropCmd, s.dropResult, nil).
+ ExpectGitArgs(s.expectedStoreCmd, "", nil)
+ instance := buildStashCommands(commonDeps{runner: runner})
+
+ err := instance.Rename(s.index, s.message)
+ assert.NoError(t, err)
+ })
+ }
+}