diff options
Diffstat (limited to 'internal/testgit/command.go')
| -rw-r--r-- | internal/testgit/command.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/internal/testgit/command.go b/internal/testgit/command.go new file mode 100644 index 00000000..cdb87a49 --- /dev/null +++ b/internal/testgit/command.go @@ -0,0 +1,36 @@ +package testgit + +import ( + "io" + "os/exec" + "testing" +) + +func (repo *Repo) Command( + tb testing.TB, + command string, + args ...string, +) *exec.Cmd { + tb.Helper() + + cmd := exec.CommandContext(tb.Context(), command, args...) + cmd.Dir = repo.path + cmd.Env = repo.env + + return cmd +} + +func (repo *Repo) Run( + tb testing.TB, + stdin io.Reader, + command string, + args ...string, +) (stdout []byte, err error) { + tb.Helper() + + cmd := repo.Command(tb, command, args...) + + cmd.Stdin = stdin + + return cmd.Output() +} |
