generated from hashicorp/packer-plugin-scaffolding
-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathdatastore_mock.go
More file actions
84 lines (67 loc) · 1.71 KB
/
datastore_mock.go
File metadata and controls
84 lines (67 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Copyright IBM Corp. 2013, 2025
// SPDX-License-Identifier: MPL-2.0
package driver
import (
"github.com/vmware/govmomi/vim25/mo"
"github.com/vmware/govmomi/vim25/types"
)
type DatastoreMock struct {
FileExistsCalled bool
FileExistsReturn bool
DirExistsCalled bool
DirExistsReturn bool
NameReturn string
MakeDirectoryCalled bool
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
}
func (ds *DatastoreMock) DirExists(path string) bool {
ds.DirExistsCalled = true
return ds.DirExistsReturn
}
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 {
ds.ResolvePathCalled = true
return ds.ResolvePathReturn
}
func (ds *DatastoreMock) UploadFile(src, dst, host string, setHost bool) error {
ds.UploadFileCalled = true
ds.UploadFileSrc = src
ds.UploadFileDst = dst
ds.UploadFileHost = host
ds.UploadFileSetHost = setHost
return ds.UploadFileErr
}
func (ds *DatastoreMock) Delete(path string) error {
ds.DeleteCalled = true
ds.DeletePath = path
return ds.DeleteErr
}
func (ds *DatastoreMock) MakeDirectory(path string) error {
ds.MakeDirectoryCalled = true
return nil
}