@@ -10,12 +10,10 @@ import (
1010
1111func TestStashDrop (t * testing.T ) {
1212runner := oscommands .NewFakeRunner (t ).
13- ExpectGitArgs ([]string {"stash" , "drop" , "stash@{1}" }, "Dropped refs/stash@{1} (98e9cca532c37c766107093010c72e26f2c24c04)" , nil )
13+ ExpectGitArgs ([]string {"stash" , "drop" , "stash@{1}" }, "Dropped refs/stash@{1} (98e9cca532c37c766107093010c72e26f2c24c04)\n " , nil )
1414instance := buildStashCommands (commonDeps {runner : runner })
1515
16- output , err := instance .Drop (1 )
17- assert .NoError (t , err )
18- assert .Equal (t , "Dropped refs/stash@{1} (98e9cca532c37c766107093010c72e26f2c24c04)" , output )
16+ assert .NoError (t , instance .Drop (1 ))
1917runner .CheckForMissingCalls ()
2018}
2119
@@ -88,6 +86,17 @@ func TestStashStore(t *testing.T) {
8886}
8987}
9088
89+ func TestStashSha (t * testing.T ) {
90+ runner := oscommands .NewFakeRunner (t ).
91+ ExpectGitArgs ([]string {"rev-parse" , "refs/stash@{5}" }, "14d94495194651adfd5f070590df566c11d28243\n " , nil )
92+ instance := buildStashCommands (commonDeps {runner : runner })
93+
94+ sha , err := instance .Sha (5 )
95+ assert .NoError (t , err )
96+ assert .Equal (t , "14d94495194651adfd5f070590df566c11d28243" , sha )
97+ runner .CheckForMissingCalls ()
98+ }
99+
91100func TestStashStashEntryCmdObj (t * testing.T ) {
92101type scenario struct {
93102testName string
@@ -129,8 +138,9 @@ func TestStashRename(t *testing.T) {
129138testName string
130139index int
131140message string
141+ expectedShaCmd []string
142+ shaResult string
132143expectedDropCmd []string
133- dropResult string
134144expectedStoreCmd []string
135145}
136146
@@ -139,16 +149,18 @@ func TestStashRename(t *testing.T) {
139149testName : "Default case" ,
140150index : 3 ,
141151message : "New message" ,
152+ expectedShaCmd : []string {"rev-parse" , "refs/stash@{3}" },
153+ shaResult : "f0d0f20f2f61ffd6d6bfe0752deffa38845a3edd\n " ,
142154expectedDropCmd : []string {"stash" , "drop" , "stash@{3}" },
143- dropResult : "Dropped refs/stash@{3} (f0d0f20f2f61ffd6d6bfe0752deffa38845a3edd)\n " ,
144155expectedStoreCmd : []string {"stash" , "store" , "f0d0f20f2f61ffd6d6bfe0752deffa38845a3edd" , "-m" , "New message" },
145156},
146157{
147158testName : "Empty message" ,
148159index : 4 ,
149160message : "" ,
161+ expectedShaCmd : []string {"rev-parse" , "refs/stash@{4}" },
162+ shaResult : "f0d0f20f2f61ffd6d6bfe0752deffa38845a3edd\n " ,
150163expectedDropCmd : []string {"stash" , "drop" , "stash@{4}" },
151- dropResult : "Dropped refs/stash@{4} (f0d0f20f2f61ffd6d6bfe0752deffa38845a3edd)\n " ,
152164expectedStoreCmd : []string {"stash" , "store" , "f0d0f20f2f61ffd6d6bfe0752deffa38845a3edd" },
153165},
154166}
@@ -157,7 +169,8 @@ func TestStashRename(t *testing.T) {
157169s := s
158170t .Run (s .testName , func (t * testing.T ) {
159171runner := oscommands .NewFakeRunner (t ).
160- ExpectGitArgs (s .expectedDropCmd , s .dropResult , nil ).
172+ ExpectGitArgs (s .expectedShaCmd , s .shaResult , nil ).
173+ ExpectGitArgs (s .expectedDropCmd , "" , nil ).
161174ExpectGitArgs (s .expectedStoreCmd , "" , nil )
162175instance := buildStashCommands (commonDeps {runner : runner })
163176
0 commit comments