From 10e19a1292cc27d394fcfed2501d456ab49da25f Mon Sep 17 00:00:00 2001 From: Paulo Truta Date: Tue, 15 Jun 2021 13:57:22 +0000 Subject: [PATCH] Finding main device in test --- internal/storage/storage.go | 4 +++- internal/storage/storage_test.go | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/internal/storage/storage.go b/internal/storage/storage.go index a20ad08..58a0744 100644 --- a/internal/storage/storage.go +++ b/internal/storage/storage.go @@ -83,7 +83,9 @@ func GetDevices() []Device { mainDiskID := "sda" - if diagnostics.Version == "prod" || diagnostics.Version == "dev" { + if diagnostics.Version == "dev" { + mainDiskID = "sda" + } else if diagnostics.Version == "prod" { mainDiskID = "mmcblk0" } else if diagnostics.Version == "cloud" { mainDiskID = "vda" diff --git a/internal/storage/storage_test.go b/internal/storage/storage_test.go index a0893bb..a28912c 100644 --- a/internal/storage/storage_test.go +++ b/internal/storage/storage_test.go @@ -14,17 +14,25 @@ func TestGetDevices(t *testing.T) { t.Fail() } + foundMainDevice := false foundDevice := false t.Log("Looking for a mmcblk0 or sda device") for _, device := range result { + + if device.MainDevice { + t.Log("Found target main device", device.ID) + foundMainDevice = true + } + if device.ID == "mmcblk0" || device.ID == "sda" { t.Log("Found target device", device.ID) foundDevice = true } + } - if !foundDevice { + if !foundDevice || !foundMainDevice { t.Log("Expected to find device mmcblk0 but did not. Devices:", result) t.Fail() }