forked from cloudfoundry/bosh-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fake_disk.go
59 lines (46 loc) · 1.16 KB
/
fake_disk.go
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
package fakes
import (
biproperty "github.com/cloudfoundry/bosh-utils/property"
)
type FakeDisk struct {
cid string
NeedsMigrationInputs []NeedsMigrationInput
needsMigrationOutput needsMigrationOutput
DeleteCalledTimes int
deleteErr error
}
type NeedsMigrationInput struct {
Size int
CloudProperties biproperty.Map
}
type needsMigrationOutput struct {
needsMigration bool
}
func NewFakeDisk(cid string) *FakeDisk {
return &FakeDisk{
cid: cid,
NeedsMigrationInputs: []NeedsMigrationInput{},
}
}
func (d *FakeDisk) CID() string {
return d.cid
}
func (d *FakeDisk) NeedsMigration(size int, cloudProperties biproperty.Map) bool {
d.NeedsMigrationInputs = append(d.NeedsMigrationInputs, NeedsMigrationInput{
Size: size,
CloudProperties: cloudProperties,
})
return d.needsMigrationOutput.needsMigration
}
func (d *FakeDisk) Delete() error {
d.DeleteCalledTimes++
return d.deleteErr
}
func (d *FakeDisk) SetNeedsMigrationBehavior(needsMigration bool) {
d.needsMigrationOutput = needsMigrationOutput{
needsMigration: needsMigration,
}
}
func (d *FakeDisk) SetDeleteBehavior(err error) {
d.deleteErr = err
}