Exemplo n.º 1
0
func (r *FakeCommandRunner) Run(cmd *exec.Cmd) error {
	r.RLock()
	callbacks := r.commandCallbacks
	r.RUnlock()

	r.Lock()
	r.executedCommands = append(r.executedCommands, cmd)
	r.Unlock()

	for spec, callback := range callbacks {
		if spec.Matches(cmd) {
			return callback(cmd)
		}
	}

	r.RLock()
	if r.process != nil {
		cmd.Process = r.process
	}
	r.RUnlock()

	return nil
}