github.com/justincormack/cli@v0.0.0-20201215022714-831ebeae9675/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 volumetypes "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(volumetypes.VolumeCreateBody) (types.Volume, error) 15 volumeInspectFunc func(volumeID string) (types.Volume, error) 16 volumeListFunc func(filter filters.Args) (volumetypes.VolumeListOKBody, 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(ctx context.Context, options volumetypes.VolumeCreateBody) (types.Volume, error) { 22 if c.volumeCreateFunc != nil { 23 return c.volumeCreateFunc(options) 24 } 25 return types.Volume{}, nil 26 } 27 28 func (c *fakeClient) VolumeInspect(ctx context.Context, volumeID string) (types.Volume, error) { 29 if c.volumeInspectFunc != nil { 30 return c.volumeInspectFunc(volumeID) 31 } 32 return types.Volume{}, nil 33 } 34 35 func (c *fakeClient) VolumeList(ctx context.Context, filter filters.Args) (volumetypes.VolumeListOKBody, error) { 36 if c.volumeListFunc != nil { 37 return c.volumeListFunc(filter) 38 } 39 return volumetypes.VolumeListOKBody{}, nil 40 } 41 42 func (c *fakeClient) VolumesPrune(ctx 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(ctx context.Context, volumeID string, force bool) error { 50 if c.volumeRemoveFunc != nil { 51 return c.volumeRemoveFunc(volumeID, force) 52 } 53 return nil 54 }