mirror of
https://github.com/edgebox-iot/edgeboxctl.git
synced 2026-11-27 15:16:54 +01:00
Finding main device in test
This commit is contained in:
@@ -83,7 +83,9 @@ func GetDevices() []Device {
|
|||||||
|
|
||||||
mainDiskID := "sda"
|
mainDiskID := "sda"
|
||||||
|
|
||||||
if diagnostics.Version == "prod" || diagnostics.Version == "dev" {
|
if diagnostics.Version == "dev" {
|
||||||
|
mainDiskID = "sda"
|
||||||
|
} else if diagnostics.Version == "prod" {
|
||||||
mainDiskID = "mmcblk0"
|
mainDiskID = "mmcblk0"
|
||||||
} else if diagnostics.Version == "cloud" {
|
} else if diagnostics.Version == "cloud" {
|
||||||
mainDiskID = "vda"
|
mainDiskID = "vda"
|
||||||
|
|||||||
@@ -14,17 +14,25 @@ func TestGetDevices(t *testing.T) {
|
|||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foundMainDevice := false
|
||||||
foundDevice := false
|
foundDevice := false
|
||||||
|
|
||||||
t.Log("Looking for a mmcblk0 or sda device")
|
t.Log("Looking for a mmcblk0 or sda device")
|
||||||
for _, device := range result {
|
for _, device := range result {
|
||||||
|
|
||||||
|
if device.MainDevice {
|
||||||
|
t.Log("Found target main device", device.ID)
|
||||||
|
foundMainDevice = true
|
||||||
|
}
|
||||||
|
|
||||||
if device.ID == "mmcblk0" || device.ID == "sda" {
|
if device.ID == "mmcblk0" || device.ID == "sda" {
|
||||||
t.Log("Found target device", device.ID)
|
t.Log("Found target device", device.ID)
|
||||||
foundDevice = true
|
foundDevice = true
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if !foundDevice {
|
if !foundDevice || !foundMainDevice {
|
||||||
t.Log("Expected to find device mmcblk0 but did not. Devices:", result)
|
t.Log("Expected to find device mmcblk0 but did not. Devices:", result)
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user