File tree Expand file tree Collapse file tree 4 files changed +19
-6
lines changed
Expand file tree Collapse file tree 4 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -350,7 +350,7 @@ func TestPRCheckout_differentRepo_existingBranch(t *testing.T) {
350350 restoreCmd := run .SetPrepareCmd (func (cmd * exec.Cmd ) run.Runnable {
351351 switch strings .Join (cmd .Args , " " ) {
352352 case "git config branch.feature.merge" :
353- return & test.OutputStub {[]byte ("refs/heads/feature\n " )}
353+ return & test.OutputStub {[]byte ("refs/heads/feature\n " ), nil }
354354 default :
355355 ranCommands = append (ranCommands , cmd .Args )
356356 return & test.OutputStub {}
@@ -400,7 +400,7 @@ func TestPRCheckout_differentRepo_currentBranch(t *testing.T) {
400400 restoreCmd := run .SetPrepareCmd (func (cmd * exec.Cmd ) run.Runnable {
401401 switch strings .Join (cmd .Args , " " ) {
402402 case "git config branch.feature.merge" :
403- return & test.OutputStub {[]byte ("refs/heads/feature\n " )}
403+ return & test.OutputStub {[]byte ("refs/heads/feature\n " ), nil }
404404 default :
405405 ranCommands = append (ranCommands , cmd .Args )
406406 return & test.OutputStub {}
Original file line number Diff line number Diff line change @@ -112,7 +112,7 @@ func TestPRStatus_fork(t *testing.T) {
112112 switch strings .Join (cmd .Args , " " ) {
113113 case `git config --get-regexp ^branch\.blueberries\.(remote|merge)$` :
114114 return & test.OutputStub {[]byte (`branch.blueberries.remote origin
115- branch.blueberries.merge refs/heads/blueberries` )}
115+ branch.blueberries.merge refs/heads/blueberries` ), nil }
116116 default :
117117 panic ("not implemented" )
118118 }
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ func Test_UncommittedChangeCount(t *testing.T) {
2727
2828 for _ , v := range cases {
2929 _ = run .SetPrepareCmd (func (* exec.Cmd ) run.Runnable {
30- return & test.OutputStub {[]byte (v .Output )}
30+ return & test.OutputStub {[]byte (v .Output ), nil }
3131 })
3232 ucc , _ := UncommittedChangeCount ()
3333
Original file line number Diff line number Diff line change 11package test
22
33import (
4+ "errors"
45 "fmt"
56 "os/exec"
67
@@ -9,14 +10,21 @@ import (
910
1011// OutputStub implements a simple utils.Runnable
1112type OutputStub struct {
12- Out []byte
13+ Out []byte
14+ Error error
1315}
1416
1517func (s OutputStub ) Output () ([]byte , error ) {
18+ if s .Error != nil {
19+ return s .Out , s .Error
20+ }
1621 return s .Out , nil
1722}
1823
1924func (s OutputStub ) Run () error {
25+ if s .Error != nil {
26+ return s .Error
27+ }
2028 return nil
2129}
2230
@@ -34,7 +42,12 @@ func InitCmdStubber() (*CmdStubber, func()) {
3442
3543func (cs * CmdStubber ) Stub (desiredOutput string ) {
3644 // TODO maybe have some kind of command mapping but going simple for now
37- cs .Stubs = append (cs .Stubs , & OutputStub {[]byte (desiredOutput )})
45+ cs .Stubs = append (cs .Stubs , & OutputStub {[]byte (desiredOutput ), nil })
46+ }
47+
48+ func (cs * CmdStubber ) StubError (msg string ) {
49+ // TODO consider handling CmdErr instead of a raw error
50+ cs .Stubs = append (cs .Stubs , & OutputStub {[]byte {}, errors .New (msg )})
3851}
3952
4053func createStubbedPrepareCmd (cs * CmdStubber ) func (* exec.Cmd ) run.Runnable {
You can’t perform that action at this time.
0 commit comments