fix testclient prepend functions

This commit is contained in:
deads2k
2015-09-28 13:28:12 -04:00
parent 7b428d8bcd
commit 4cc63313e7
4 changed files with 21 additions and 17 deletions

View File

@@ -40,6 +40,8 @@ func NewSimpleFake(objects ...runtime.Object) *Fake {
fakeClient := &Fake{}
fakeClient.AddReactor("*", "*", ObjectReaction(o, api.RESTMapper))
fakeClient.AddWatchReactor("*", DefaultWatchReactor(watch.NewFake(), nil))
return fakeClient
}
@@ -100,9 +102,7 @@ func (c *Fake) AddReactor(verb, resource string, reaction ReactionFunc) {
// PrependReactor adds a reactor to the beginning of the chain
func (c *Fake) PrependReactor(verb, resource string, reaction ReactionFunc) {
newChain := make([]Reactor, 0, len(c.ReactionChain)+1)
newChain[0] = &SimpleReactor{verb, resource, reaction}
newChain = append(newChain, c.ReactionChain...)
c.ReactionChain = append([]Reactor{&SimpleReactor{verb, resource, reaction}}, c.ReactionChain...)
}
// AddWatchReactor appends a reactor to the end of the chain
@@ -110,11 +110,21 @@ func (c *Fake) AddWatchReactor(resource string, reaction WatchReactionFunc) {
c.WatchReactionChain = append(c.WatchReactionChain, &SimpleWatchReactor{resource, reaction})
}
// PrependWatchReactor adds a reactor to the beginning of the chain
func (c *Fake) PrependWatchReactor(resource string, reaction WatchReactionFunc) {
c.WatchReactionChain = append([]WatchReactor{&SimpleWatchReactor{resource, reaction}}, c.WatchReactionChain...)
}
// AddProxyReactor appends a reactor to the end of the chain
func (c *Fake) AddProxyReactor(resource string, reaction ProxyReactionFunc) {
c.ProxyReactionChain = append(c.ProxyReactionChain, &SimpleProxyReactor{resource, reaction})
}
// PrependProxyReactor adds a reactor to the beginning of the chain
func (c *Fake) PrependProxyReactor(resource string, reaction ProxyReactionFunc) {
c.ProxyReactionChain = append([]ProxyReactor{&SimpleProxyReactor{resource, reaction}}, c.ProxyReactionChain...)
}
// Invokes records the provided Action and then invokes the ReactFn (if provided).
// defaultReturnObj is expected to be of the same type a normal call would return.
func (c *Fake) Invokes(action Action, defaultReturnObj runtime.Object) (runtime.Object, error) {