forked from cloudfoundry/bosh-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fake_partitioner.go
53 lines (43 loc) · 1.63 KB
/
fake_partitioner.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
package fakes
import (
boshdisk "github.com/cloudfoundry/bosh-agent/platform/disk"
)
type FakePartitioner struct {
PartitionCalled bool
PartitionDevicePath string
PartitionPartitions []boshdisk.Partition
PartitionErr error
GetDeviceSizeInBytesDevicePath string
GetDeviceSizeInBytesSizes map[string]uint64
GetDeviceSizeInBytesErr error
GetPartitionsPartitions []boshdisk.ExistingPartition
GetPartitionsSizes map[string]uint64
GetPartitionsErr error
RemovePartitionsCalled bool
RemoveExistingPartition []boshdisk.ExistingPartition
RemovePartitionsErr error
}
func NewFakePartitioner() *FakePartitioner {
return &FakePartitioner{
GetDeviceSizeInBytesSizes: make(map[string]uint64),
}
}
func (p *FakePartitioner) Partition(devicePath string, partitions []boshdisk.Partition) error {
p.PartitionCalled = true
p.PartitionDevicePath = devicePath
p.PartitionPartitions = partitions
return p.PartitionErr
}
func (p *FakePartitioner) GetDeviceSizeInBytes(devicePath string) (uint64, error) {
p.GetDeviceSizeInBytesDevicePath = devicePath
return p.GetDeviceSizeInBytesSizes[devicePath], p.GetDeviceSizeInBytesErr
}
func (p *FakePartitioner) GetPartitions(devicePath string) (partitions []boshdisk.ExistingPartition, deviceFullSizeInBytes uint64, err error) {
return p.GetPartitionsPartitions, p.GetPartitionsSizes[devicePath], p.GetPartitionsErr
}
func (p *FakePartitioner) RemovePartitions(partitions []boshdisk.ExistingPartition, devicePath string) error {
p.RemovePartitionsCalled = true
p.RemoveExistingPartition = partitions
p.PartitionDevicePath = devicePath
return p.RemovePartitionsErr
}