github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/storage/provider/dummy/filesystemsource.go (about) 1 // Copyright 2017 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package dummy 5 6 import ( 7 "github.com/juju/errors" 8 "github.com/juju/testing" 9 10 "github.com/juju/juju/environs/context" 11 "github.com/juju/juju/storage" 12 ) 13 14 // FilesystemSource is an implementation of storage.FilesystemSource, suitable for 15 // testing. Each method's default behaviour may be overridden by setting 16 // the corresponding Func field. 17 type FilesystemSource struct { 18 testing.Stub 19 20 CreateFilesystemsFunc func(context.ProviderCallContext, []storage.FilesystemParams) ([]storage.CreateFilesystemsResult, error) 21 DestroyFilesystemsFunc func(context.ProviderCallContext, []string) ([]error, error) 22 ReleaseFilesystemsFunc func(context.ProviderCallContext, []string) ([]error, error) 23 ValidateFilesystemParamsFunc func(storage.FilesystemParams) error 24 AttachFilesystemsFunc func(context.ProviderCallContext, []storage.FilesystemAttachmentParams) ([]storage.AttachFilesystemsResult, error) 25 DetachFilesystemsFunc func(context.ProviderCallContext, []storage.FilesystemAttachmentParams) ([]error, error) 26 } 27 28 // CreateFilesystems is defined on storage.FilesystemSource. 29 func (s *FilesystemSource) CreateFilesystems(ctx context.ProviderCallContext, params []storage.FilesystemParams) ([]storage.CreateFilesystemsResult, error) { 30 s.MethodCall(s, "CreateFilesystems", ctx, params) 31 if s.CreateFilesystemsFunc != nil { 32 return s.CreateFilesystemsFunc(ctx, params) 33 } 34 return nil, errors.NotImplementedf("CreateFilesystems") 35 } 36 37 // DestroyFilesystems is defined on storage.FilesystemSource. 38 func (s *FilesystemSource) DestroyFilesystems(ctx context.ProviderCallContext, volIds []string) ([]error, error) { 39 s.MethodCall(s, "DestroyFilesystems", ctx, volIds) 40 if s.DestroyFilesystemsFunc != nil { 41 return s.DestroyFilesystemsFunc(ctx, volIds) 42 } 43 return nil, errors.NotImplementedf("DestroyFilesystems") 44 } 45 46 // ReleaseFilesystems is defined on storage.FilesystemSource. 47 func (s *FilesystemSource) ReleaseFilesystems(ctx context.ProviderCallContext, volIds []string) ([]error, error) { 48 s.MethodCall(s, "ReleaseFilesystems", ctx, volIds) 49 if s.ReleaseFilesystemsFunc != nil { 50 return s.ReleaseFilesystemsFunc(ctx, volIds) 51 } 52 return nil, errors.NotImplementedf("ReleaseFilesystems") 53 } 54 55 // ValidateFilesystemParams is defined on storage.FilesystemSource. 56 func (s *FilesystemSource) ValidateFilesystemParams(params storage.FilesystemParams) error { 57 s.MethodCall(s, "ValidateFilesystemParams", params) 58 if s.ValidateFilesystemParamsFunc != nil { 59 return s.ValidateFilesystemParamsFunc(params) 60 } 61 return nil 62 } 63 64 // AttachFilesystems is defined on storage.FilesystemSource. 65 func (s *FilesystemSource) AttachFilesystems(ctx context.ProviderCallContext, params []storage.FilesystemAttachmentParams) ([]storage.AttachFilesystemsResult, error) { 66 s.MethodCall(s, "AttachFilesystems", ctx, params) 67 if s.AttachFilesystemsFunc != nil { 68 return s.AttachFilesystemsFunc(ctx, params) 69 } 70 return nil, errors.NotImplementedf("AttachFilesystems") 71 } 72 73 // DetachFilesystems is defined on storage.FilesystemSource. 74 func (s *FilesystemSource) DetachFilesystems(ctx context.ProviderCallContext, params []storage.FilesystemAttachmentParams) ([]error, error) { 75 s.MethodCall(s, "DetachFilesystems", ctx, params) 76 if s.DetachFilesystemsFunc != nil { 77 return s.DetachFilesystemsFunc(ctx, params) 78 } 79 return nil, errors.NotImplementedf("DetachFilesystems") 80 }