func()

in exec/testing/fake_exec.go [48:75]


func (fake *FakeExec) Command(cmd string, args ...string) exec.Cmd {
	if fake.DisableScripts {
		fakeCmd := &FakeCmd{DisableScripts: true}
		return InitFakeCmd(fakeCmd, cmd, args...)
	}
	if fake.CommandCalls > len(fake.CommandScript)-1 {
		panic(fmt.Sprintf("ran out of Command() actions. Could not handle command [%d]: %s args: %v", fake.CommandCalls, cmd, args))
	}
	i := fake.CommandCalls
	fake.CommandCalls++
	fakeCmd := fake.CommandScript[i](cmd, args...)
	if fake.ExactOrder {
		argv := append([]string{cmd}, args...)
		fc := fakeCmd.(*FakeCmd)
		if cmd != fc.Argv[0] {
			panic(fmt.Sprintf("received command: %s, expected: %s", cmd, fc.Argv[0]))
		}
		if len(argv) != len(fc.Argv) {
			panic(fmt.Sprintf("command (%s) received with extra/missing arguments. Expected %v, Received %v", cmd, fc.Argv, argv))
		}
		for i, a := range argv[1:] {
			if a != fc.Argv[i+1] {
				panic(fmt.Sprintf("command (%s) called with unexpected argument. Expected %s, Received %s", cmd, fc.Argv[i+1], a))
			}
		}
	}
	return fakeCmd
}