TestGetDevices

pull/13/head
Paulo Truta 2021-06-12 14:55:29 +00:00
parent 7c14dfee64
commit 6d3c1df1f5
1 changed files with 19 additions and 2 deletions

View File

@ -3,12 +3,29 @@
package storage
import (
"fmt"
"testing"
)
func TestGetDevices(t *testing.T) {
result := GetDevices()
fmt.Println(result)
if len(result) == 0 {
t.Log("Expecting at least 1 block device, 0 elements found in slice")
t.Fail()
}
foundDevice := false
t.Log("Looking for a mmcblk0 or sda device")
for _, device := range result {
if device.ID == "mmcblk0" || device.ID == "sda" {
t.Log("Found target device", device.ID)
foundDevice = true
}
}
if !foundDevice {
t.Log("Expected to find device mmcblk0 but did not. Devices:", result)
t.Fail()
}
}