github.com/khulnasoft/cli@v0.0.0-20240402070845-01bcad7beefa/cli/command/volume/client_test.go (about) 1 package volume 2 3 import ( 4 "context" 5 6 "github.com/docker/docker/api/types" 7 "github.com/docker/docker/api/types/filters" 8 "github.com/docker/docker/api/types/volume" 9 "github.com/docker/docker/client" 10 ) 11 12 type fakeClient struct { 13 client.Client 14 volumeCreateFunc func(volume.CreateOptions) (volume.Volume, error) 15 volumeInspectFunc func(volumeID string) (volume.Volume, error) 16 volumeListFunc func(filter filters.Args) (volume.ListResponse, error) 17 volumeRemoveFunc func(volumeID string, force bool) error 18 volumePruneFunc func(filter filters.Args) (types.VolumesPruneReport, error) 19 } 20 21 func (c *fakeClient) VolumeCreate(_ context.Context, options volume.CreateOptions) (volume.Volume, error) { 22 if c.volumeCreateFunc != nil { 23 return c.volumeCreateFunc(options) 24 } 25 return volume.Volume{}, nil 26 } 27 28 func (c *fakeClient) VolumeInspect(_ context.Context, volumeID string) (volume.Volume, error) { 29 if c.volumeInspectFunc != nil { 30 return c.volumeInspectFunc(volumeID) 31 } 32 return volume.Volume{}, nil 33 } 34 35 func (c *fakeClient) VolumeList(_ context.Context, options volume.ListOptions) (volume.ListResponse, error) { 36 if c.volumeListFunc != nil { 37 return c.volumeListFunc(options.Filters) 38 } 39 return volume.ListResponse{}, nil 40 } 41 42 func (c *fakeClient) VolumesPrune(_ context.Context, filter filters.Args) (types.VolumesPruneReport, error) { 43 if c.volumePruneFunc != nil { 44 return c.volumePruneFunc(filter) 45 } 46 return types.VolumesPruneReport{}, nil 47 } 48 49 func (c *fakeClient) VolumeRemove(_ context.Context, volumeID string, force bool) error { 50 if c.volumeRemoveFunc != nil { 51 return c.volumeRemoveFunc(volumeID, force) 52 } 53 return nil 54 }