Skip to content

Commit d67b248

Browse files
author
ymqytw
committed
address comments
1 parent c7bfd26 commit d67b248

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

exec/exec.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
// ErrExecutableNotFound is returned if the executable is not found.
2727
var ErrExecutableNotFound = osexec.ErrNotFound
2828

29-
// Interface is an interface that presents a subset of the os/exec API. Use this
29+
// Interface is an interface that presents a subset of the os/exec API. Use this
3030
// when you want to inject fakeable/mockable exec behavior.
3131
type Interface interface {
3232
// Command returns a Cmd instance which can be used to run a single command.
@@ -38,13 +38,13 @@ type Interface interface {
3838
}
3939

4040
// Cmd is an interface that presents an API that is very similar to Cmd from os/exec.
41-
// As more functionality is needed, this can grow. Since Cmd is a struct, we will have
41+
// As more functionality is needed, this can grow. Since Cmd is a struct, we will have
4242
// to replace fields with get/set method pairs.
4343
type Cmd interface {
4444
// Run runs the command to the completion.
4545
Run() error
4646
// CombinedOutput runs the command and returns its combined standard output
47-
// and standard error. This follows the pattern of package os/exec.
47+
// and standard error. This follows the pattern of package os/exec.
4848
CombinedOutput() ([]byte, error)
4949
// Output runs the command and returns standard output, but not standard err
5050
Output() ([]byte, error)
@@ -60,7 +60,7 @@ type Cmd interface {
6060
}
6161

6262
// ExitError is an interface that presents an API similar to os.ProcessState, which is
63-
// what ExitError from os/exec is. This is designed to make testing a bit easier and
63+
// what ExitError from os/exec is. This is designed to make testing a bit easier and
6464
// probably loses some of the cross-platform properties of the underlying library.
6565
type ExitError interface {
6666
String() string
@@ -90,6 +90,8 @@ func (executor *executor) LookPath(file string) (string, error) {
9090
// Wraps exec.Cmd so we can capture errors.
9191
type cmdWrapper osexec.Cmd
9292

93+
var _ Cmd = &cmdWrapper{}
94+
9395
func (cmd *cmdWrapper) SetDir(dir string) {
9496
cmd.Dir = dir
9597
}

exec/testing/fake_exec.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package exec
17+
package testingexec
1818

1919
import (
2020
"fmt"
@@ -60,6 +60,8 @@ type FakeCmd struct {
6060
Stderr io.Writer
6161
}
6262

63+
var _ exec.Cmd = &FakeCmd{}
64+
6365
func InitFakeCmd(fake *FakeCmd, cmd string, args ...string) exec.Cmd {
6466
fake.Argv = append([]string{cmd}, args...)
6567
return fake
@@ -130,6 +132,8 @@ type FakeExitError struct {
130132
Status int
131133
}
132134

135+
var _ exec.ExitError = FakeExitError{}
136+
133137
func (fake *FakeExitError) String() string {
134138
return fmt.Sprintf("exit %d", fake.Status)
135139
}

0 commit comments

Comments
 (0)