Invokes records the provided Action and then invokes the ReactionFunc that handles the action if one exists. defaultReturnObj is expected to be of the same type a normal call would return.
(action Action, defaultReturnObj runtime.Object)
| 128 | // handles the action if one exists. defaultReturnObj is expected to be of the |
| 129 | // same type a normal call would return. |
| 130 | func (c *Fake) Invokes(action Action, defaultReturnObj runtime.Object) (runtime.Object, error) { |
| 131 | c.Lock() |
| 132 | defer c.Unlock() |
| 133 | |
| 134 | actionCopy := action.DeepCopy() |
| 135 | c.actions = append(c.actions, action.DeepCopy()) |
| 136 | for _, reactor := range c.ReactionChain { |
| 137 | if !reactor.Handles(actionCopy) { |
| 138 | continue |
| 139 | } |
| 140 | |
| 141 | handled, ret, err := reactor.React(actionCopy) |
| 142 | if !handled { |
| 143 | continue |
| 144 | } |
| 145 | |
| 146 | return ret, err |
| 147 | } |
| 148 | |
| 149 | return defaultReturnObj, nil |
| 150 | } |
| 151 | |
| 152 | // InvokesWatch records the provided Action and then invokes the ReactionFunc |
| 153 | // that handles the action if one exists. |