INNER CODE UNIT · Go
func
cristianoliveira/ergo · main_test.go:162
func (r *TestRunnerWithOutput) Mock(command string, output []byte) {
// parse command to a unique key
key := strings.Join(strings.Split(command, " "), "_")
r.MockedOutput[key] = output
}
func (r *TestRunnerWithOutput) Run(command string, args ...string) ([]byte, error) {
commandWithArgs := command + " " + strings.Join(args, " ")
key := strings.Join(strings.Split(commandWithArgs, " "), "_")
mockedOutput, ok := r.MockedOutput[key]
if !ok {
return r.OriginalRunner.Run(command, args...)
}
return mockedOutput, nil
}