mirror of
https://github.com/edgebox-iot/edgeboxctl.git
synced 2026-11-26 14:48:31 +01:00
45 lines
961 B
Go
45 lines
961 B
Go
// +build unit
|
|
|
|
package storage
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestGetDevices(t *testing.T) {
|
|
|
|
t.Log("Testing with release version dev")
|
|
assertGetDevices(GetDevices("dev"), t)
|
|
t.Log("Testing with release version prod")
|
|
assertGetDevices(GetDevices("prod"), t)
|
|
t.Log("Testing with release version cloud")
|
|
assertGetDevices(GetDevices("cloud"), t)
|
|
|
|
}
|
|
|
|
func assertGetDevices(devices []Device, t *testing.T) {
|
|
|
|
if len(devices) == 0 {
|
|
t.Log("Expecting at least 1 block device, 0 elements found in slice")
|
|
t.Fail()
|
|
}
|
|
|
|
foundDevice := false
|
|
|
|
t.Log("Looking for a mmcblk0, sda, vda or nvme device")
|
|
for _, device := range devices {
|
|
|
|
if device.ID == "mmcblk0" || device.ID == "sda" || device.ID == "vda" || strings.HasPrefix(device.ID, "nvme") {
|
|
t.Log("Found target device", device.ID)
|
|
foundDevice = true
|
|
}
|
|
|
|
}
|
|
|
|
if !foundDevice {
|
|
t.Log("Expected to find device mmcblk0, sda, vda or nvme but did not. Devices:", devices)
|
|
t.Fail()
|
|
}
|
|
}
|