Skip to content

Commit 65d57e5

Browse files
author
Alfonso Acosta
committed
Add SetEnv() to Cmd mocking interface
1 parent ceec9d7 commit 65d57e5

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

exec/exec.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ type Cmd interface {
1414
Kill() error
1515
Output() ([]byte, error)
1616
Run() error
17+
SetEnv([]string)
1718
}
1819

1920
// Command is a hook for mocking
@@ -28,3 +29,7 @@ type realCmd struct {
2829
func (c *realCmd) Kill() error {
2930
return c.Cmd.Process.Kill()
3031
}
32+
33+
func (c *realCmd) SetEnv(env []string) {
34+
c.Cmd.Env = env
35+
}

test/exec/exec.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ func (c *mockCmd) Run() error {
6868
return nil
6969
}
7070

71+
func (c *mockCmd) SetEnv([]string) {}
72+
7173
func (b *blockingReader) Read(p []byte) (n int, err error) {
7274
<-b.quit
7375
return 0, nil

0 commit comments

Comments
 (0)