Skip to content

Commit f5a3c0d

Browse files
committed
test(ns/sys): resolve block device to physical device
longhorn/longhorn-12344 Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
1 parent 846e6b8 commit f5a3c0d

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

ns/joiner_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ func TestNamespaceMethods(t *testing.T) {
130130
testCaseSync(t),
131131
testCaseGetOSDistro(t),
132132
testCaseGetSystemBlockDevices(t),
133+
testCaseResolveBlockDeviceToPhysicalDevice(t),
133134
testCaseCopyDirectory(t),
134135
testCaseCreateDirectory(t),
135136
testCaseDeleteDirectory(t),

ns/sys_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,29 @@ func testCaseGetSystemBlockDevices(t *testing.T) map[string]testCaseNamespaceMet
124124
},
125125
}
126126
}
127+
128+
func testCaseResolveBlockDeviceToPhysicalDevice(t *testing.T) map[string]testCaseNamespaceMethods {
129+
return map[string]testCaseNamespaceMethods{
130+
"ResolveBlockDeviceToPhysicalDevice/Local": {
131+
method: func(args ...interface{}) (interface{}, error) {
132+
return ResolveBlockDeviceToPhysicalDevice("/dev/sda1")
133+
},
134+
mockResult: "/dev/sda",
135+
expected: "/dev/sda",
136+
},
137+
"ResolveBlockDeviceToPhysicalDevice/Failed to run": {
138+
method: func(args ...interface{}) (interface{}, error) {
139+
return ResolveBlockDeviceToPhysicalDevice("/dev/sda1")
140+
},
141+
mockError: fmt.Errorf("failed"),
142+
expectError: true,
143+
},
144+
"ResolveBlockDeviceToPhysicalDevice/Failed to cast result": {
145+
method: func(args ...interface{}) (interface{}, error) {
146+
return ResolveBlockDeviceToPhysicalDevice("/dev/sda1")
147+
},
148+
mockResult: int(1),
149+
expectError: true,
150+
},
151+
}
152+
}

0 commit comments

Comments
 (0)