mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 07:27:21 +00:00
fix testclient prepend functions
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user