Finding main device in test
parent
33ab2377c0
commit
10e19a1292
|
@ -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()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue