github.com/itscaro/cli@v0.0.0-20190705081621-c9db0fe93829/cli/command/plugin/client_test.go (about) 1 package plugin 2 3 import ( 4 "context" 5 "io" 6 7 "github.com/docker/docker/api/types" 8 "github.com/docker/docker/api/types/filters" 9 "github.com/docker/docker/client" 10 ) 11 12 type fakeClient struct { 13 client.Client 14 pluginCreateFunc func(createContext io.Reader, createOptions types.PluginCreateOptions) error 15 pluginDisableFunc func(name string, disableOptions types.PluginDisableOptions) error 16 pluginEnableFunc func(name string, options types.PluginEnableOptions) error 17 pluginRemoveFunc func(name string, options types.PluginRemoveOptions) error 18 pluginInstallFunc func(name string, options types.PluginInstallOptions) (io.ReadCloser, error) 19 pluginListFunc func(filter filters.Args) (types.PluginsListResponse, error) 20 pluginInspectFunc func(name string) (*types.Plugin, []byte, error) 21 } 22 23 func (c *fakeClient) PluginCreate(ctx context.Context, createContext io.Reader, createOptions types.PluginCreateOptions) error { 24 if c.pluginCreateFunc != nil { 25 return c.pluginCreateFunc(createContext, createOptions) 26 } 27 return nil 28 } 29 30 func (c *fakeClient) PluginEnable(ctx context.Context, name string, enableOptions types.PluginEnableOptions) error { 31 if c.pluginEnableFunc != nil { 32 return c.pluginEnableFunc(name, enableOptions) 33 } 34 return nil 35 } 36 37 func (c *fakeClient) PluginDisable(context context.Context, name string, disableOptions types.PluginDisableOptions) error { 38 if c.pluginDisableFunc != nil { 39 return c.pluginDisableFunc(name, disableOptions) 40 } 41 return nil 42 } 43 44 func (c *fakeClient) PluginRemove(context context.Context, name string, removeOptions types.PluginRemoveOptions) error { 45 if c.pluginRemoveFunc != nil { 46 return c.pluginRemoveFunc(name, removeOptions) 47 } 48 return nil 49 } 50 51 func (c *fakeClient) PluginInstall(context context.Context, name string, installOptions types.PluginInstallOptions) (io.ReadCloser, error) { 52 if c.pluginInstallFunc != nil { 53 return c.pluginInstallFunc(name, installOptions) 54 } 55 return nil, nil 56 } 57 58 func (c *fakeClient) PluginList(context context.Context, filter filters.Args) (types.PluginsListResponse, error) { 59 if c.pluginListFunc != nil { 60 return c.pluginListFunc(filter) 61 } 62 63 return types.PluginsListResponse{}, nil 64 } 65 66 func (c *fakeClient) PluginInspectWithRaw(ctx context.Context, name string) (*types.Plugin, []byte, error) { 67 if c.pluginInspectFunc != nil { 68 return c.pluginInspectFunc(name) 69 } 70 71 return nil, nil, nil 72 } 73 74 func (c *fakeClient) Info(ctx context.Context) (types.Info, error) { 75 return types.Info{}, nil 76 }