packer-cn/builder/vsphere/driver/datastore_mock.go

82 lines
1.6 KiB
Go
Raw Normal View History

package driver
import (
"github.com/vmware/govmomi/vim25/mo"
"github.com/vmware/govmomi/vim25/types"
)
type DatastoreMock struct {
FileExistsCalled bool
FileExistsReturn bool
2020-10-23 18:35:37 -04:00
DirExistsCalled bool
DirExistsReturn bool
NameReturn string
MakeDirectoryCalled bool
2020-09-22 10:19:30 -04:00
ResolvePathCalled bool
ResolvePathReturn string
DeleteCalled bool
DeletePath string
DeleteErr error
UploadFileCalled bool
UploadFileSrc string
UploadFileDst string
UploadFileHost string
UploadFileSetHost bool
UploadFileErr error
}
func (ds *DatastoreMock) Info(params ...string) (*mo.Datastore, error) {
return nil, nil
}
func (ds *DatastoreMock) FileExists(path string) bool {
ds.FileExistsCalled = true
return ds.FileExistsReturn
}
2020-10-23 14:04:27 -04:00
func (ds *DatastoreMock) DirExists(path string) bool {
2020-10-23 18:35:37 -04:00
ds.DirExistsCalled = true
return ds.DirExistsReturn
2020-10-23 14:04:27 -04:00
}
func (ds *DatastoreMock) Name() string {
if ds.NameReturn == "" {
return "datastore-mock"
}
return ds.NameReturn
}
func (ds *DatastoreMock) Reference() types.ManagedObjectReference {
return types.ManagedObjectReference{}
}
func (ds *DatastoreMock) ResolvePath(path string) string {
2020-09-22 10:19:30 -04:00
ds.ResolvePathCalled = true
return ds.ResolvePathReturn
}
func (ds *DatastoreMock) UploadFile(src, dst, host string, setHost bool) error {
ds.UploadFileCalled = true
2020-09-22 10:19:30 -04:00
ds.UploadFileSrc = src
ds.UploadFileDst = dst
ds.UploadFileHost = host
ds.UploadFileSetHost = setHost
return ds.UploadFileErr
}
func (ds *DatastoreMock) Delete(path string) error {
2020-09-22 10:19:30 -04:00
ds.DeleteCalled = true
ds.DeletePath = path
return ds.DeleteErr
}
func (ds *DatastoreMock) MakeDirectory(path string) error {
ds.MakeDirectoryCalled = true
return nil
}