forked from juju/juju
-
Notifications
You must be signed in to change notification settings - Fork 0
/
path_test.go
54 lines (43 loc) · 1.48 KB
/
path_test.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
// Copyright 2014 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package blockdevice_test
import (
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
"github.com/juju/juju/core/blockdevice"
)
type BlockDevicePathSuite struct{}
var _ = gc.Suite(&BlockDevicePathSuite{})
func (s *BlockDevicePathSuite) TestBlockDevicePathSerial(c *gc.C) {
testBlockDevicePath(c, blockdevice.BlockDevice{
HardwareId: "SPR_OSUM_123",
DeviceName: "name",
}, "/dev/disk/by-id/SPR_OSUM_123")
}
func (s *BlockDevicePathSuite) TestBlockDevicePathWWN(c *gc.C) {
testBlockDevicePath(c, blockdevice.BlockDevice{
HardwareId: "SPR_OSUM_123",
WWN: "rr!",
DeviceName: "name",
}, "/dev/disk/by-id/wwn-rr!")
}
func (s *BlockDevicePathSuite) TestBlockDevicePathUUID(c *gc.C) {
testBlockDevicePath(c, blockdevice.BlockDevice{
UUID: "deadbeaf",
DeviceName: "name",
}, "/dev/disk/by-uuid/deadbeaf")
}
func (s *BlockDevicePathSuite) TestBlockDevicePathDeviceName(c *gc.C) {
testBlockDevicePath(c, blockdevice.BlockDevice{
DeviceName: "name",
}, "/dev/name")
}
func (s *BlockDevicePathSuite) TestBlockDevicePathError(c *gc.C) {
_, err := blockdevice.BlockDevicePath(blockdevice.BlockDevice{})
c.Assert(err, gc.ErrorMatches, `could not determine path for block device`)
}
func testBlockDevicePath(c *gc.C, dev blockdevice.BlockDevice, expect string) {
path, err := blockdevice.BlockDevicePath(dev)
c.Assert(err, jc.ErrorIsNil)
c.Assert(path, jc.SamePath, expect)
}