From 6d3c1df1f539bfa47842a3339ca98fa1e2e7dba8 Mon Sep 17 00:00:00 2001 From: Paulo Truta Date: Sat, 12 Jun 2021 14:55:29 +0000 Subject: [PATCH] TestGetDevices --- internal/storage/storage_test.go | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/internal/storage/storage_test.go b/internal/storage/storage_test.go index a7180a8..a0893bb 100644 --- a/internal/storage/storage_test.go +++ b/internal/storage/storage_test.go @@ -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() + } }