github.com/mwhudson/juju@v0.0.0-20160512215208-90ff01f3497f/storage/provider/dummy/volumesource.go (about) 1 package dummy 2 3 import ( 4 "github.com/juju/errors" 5 "github.com/juju/testing" 6 7 "github.com/juju/juju/storage" 8 ) 9 10 // VolumeSource is an implementation of storage.VolumeSource, suitable for 11 // testing. Each method's default behaviour may be overridden by setting 12 // the corresponding Func field. 13 type VolumeSource struct { 14 testing.Stub 15 16 CreateVolumesFunc func([]storage.VolumeParams) ([]storage.CreateVolumesResult, error) 17 ListVolumesFunc func() ([]string, error) 18 DescribeVolumesFunc func([]string) ([]storage.DescribeVolumesResult, error) 19 DestroyVolumesFunc func([]string) ([]error, error) 20 ValidateVolumeParamsFunc func(storage.VolumeParams) error 21 AttachVolumesFunc func([]storage.VolumeAttachmentParams) ([]storage.AttachVolumesResult, error) 22 DetachVolumesFunc func([]storage.VolumeAttachmentParams) ([]error, error) 23 } 24 25 // CreateVolumes is defined on storage.VolumeSource. 26 func (s *VolumeSource) CreateVolumes(params []storage.VolumeParams) ([]storage.CreateVolumesResult, error) { 27 s.MethodCall(s, "CreateVolumes", params) 28 if s.CreateVolumesFunc != nil { 29 return s.CreateVolumesFunc(params) 30 } 31 return nil, errors.NotImplementedf("CreateVolumes") 32 } 33 34 // ListVolumes is defined on storage.VolumeSource. 35 func (s *VolumeSource) ListVolumes() ([]string, error) { 36 s.MethodCall(s, "ListVolumes") 37 if s.ListVolumesFunc != nil { 38 return s.ListVolumesFunc() 39 } 40 return nil, nil 41 } 42 43 // DescribeVolumes is defined on storage.VolumeSource. 44 func (s *VolumeSource) DescribeVolumes(volIds []string) ([]storage.DescribeVolumesResult, error) { 45 s.MethodCall(s, "DescribeVolumes", volIds) 46 if s.DescribeVolumesFunc != nil { 47 return s.DescribeVolumesFunc(volIds) 48 } 49 return nil, errors.NotImplementedf("DescribeVolumes") 50 } 51 52 // DestroyVolumes is defined on storage.VolumeSource. 53 func (s *VolumeSource) DestroyVolumes(volIds []string) ([]error, error) { 54 s.MethodCall(s, "DestroyVolumes", volIds) 55 if s.DestroyVolumesFunc != nil { 56 return s.DestroyVolumesFunc(volIds) 57 } 58 return nil, errors.NotImplementedf("DestroyVolumes") 59 } 60 61 // ValidateVolumeParams is defined on storage.VolumeSource. 62 func (s *VolumeSource) ValidateVolumeParams(params storage.VolumeParams) error { 63 s.MethodCall(s, "ValidateVolumeParams", params) 64 if s.ValidateVolumeParamsFunc != nil { 65 return s.ValidateVolumeParamsFunc(params) 66 } 67 return nil 68 } 69 70 // AttachVolumes is defined on storage.VolumeSource. 71 func (s *VolumeSource) AttachVolumes(params []storage.VolumeAttachmentParams) ([]storage.AttachVolumesResult, error) { 72 s.MethodCall(s, "AttachVolumes", params) 73 if s.AttachVolumesFunc != nil { 74 return s.AttachVolumesFunc(params) 75 } 76 return nil, errors.NotImplementedf("AttachVolumes") 77 } 78 79 // DetachVolumes is defined on storage.VolumeSource. 80 func (s *VolumeSource) DetachVolumes(params []storage.VolumeAttachmentParams) ([]error, error) { 81 s.MethodCall(s, "DetachVolumes", params) 82 if s.DetachVolumesFunc != nil { 83 return s.DetachVolumesFunc(params) 84 } 85 return nil, errors.NotImplementedf("DetachVolumes") 86 }