mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 12:25:47 +02:00
update tests
This commit is contained in:
parent
3911575041
commit
95b2e9540a
15 changed files with 92 additions and 124 deletions
|
@ -3,6 +3,7 @@ package oscommands
|
|||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
|
@ -93,10 +94,24 @@ func (self *FakeCmdObjRunner) ExpectArgs(expectedArgs []string, output string, e
|
|||
return self
|
||||
}
|
||||
|
||||
func (self *FakeCmdObjRunner) ExpectGitArgs(expectedArgs []string, output string, err error) *FakeCmdObjRunner {
|
||||
self.ExpectFunc(func(cmdObj ICmdObj) (string, error) {
|
||||
// first arg is 'git' on unix and something like '"C:\\Program Files\\Git\\mingw64\\bin\\git.exe" on windows so we'll just ensure it ends in either 'git' or 'git.exe'
|
||||
re := regexp.MustCompile(`git(\.exe)?$`)
|
||||
args := cmdObj.GetCmd().Args
|
||||
if !re.MatchString(args[0]) {
|
||||
self.t.Errorf("expected first arg to end in .git or .git.exe but was %s", args[0])
|
||||
}
|
||||
assert.EqualValues(self.t, expectedArgs, args[1:], fmt.Sprintf("command %d did not match expectation", self.expectedCmdIndex+1))
|
||||
|
||||
return output, err
|
||||
})
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *FakeCmdObjRunner) CheckForMissingCalls() {
|
||||
if self.expectedCmdIndex < len(self.expectedCmds) {
|
||||
self.t.Errorf("expected command %d to be called, but was not", self.expectedCmdIndex+1)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue