github.com/openshift/docker-source-to-images@v1.2.0/pkg/test/cmd/cmd.go (about) 1 package cmd 2 3 import ( 4 "bytes" 5 "io" 6 "io/ioutil" 7 8 "github.com/openshift/source-to-image/pkg/util/cmd" 9 ) 10 11 // FakeCmdRunner provider the fake command runner 12 type FakeCmdRunner struct { 13 Name string 14 Args []string 15 Opts cmd.CommandOpts 16 Err error 17 } 18 19 // RunWithOptions runs the command runner with extra options 20 func (f *FakeCmdRunner) RunWithOptions(opts cmd.CommandOpts, name string, args ...string) error { 21 f.Name = name 22 f.Args = args 23 f.Opts = opts 24 return f.Err 25 } 26 27 // Run runs the fake command runner 28 func (f *FakeCmdRunner) Run(name string, args ...string) error { 29 return f.RunWithOptions(cmd.CommandOpts{}, name, args...) 30 } 31 32 // StartWithStdoutPipe executes a command returning a ReadCloser connected to 33 // the command's stdout. 34 func (f *FakeCmdRunner) StartWithStdoutPipe(opts cmd.CommandOpts, name string, arg ...string) (io.ReadCloser, error) { 35 return ioutil.NopCloser(&bytes.Buffer{}), f.Err 36 } 37 38 // Wait waits for the command to exit. 39 func (f *FakeCmdRunner) Wait() error { 40 return f.Err 41 }