mirror of
https://github.com/edgebox-iot/edgeboxctl.git
synced 2026-09-25 06:13:03 +02:00
* Added build-cloud to Makefile * Fix env var key GOOS * Added taskSetReleaseVersion for edgeboxctl version option write into DB * taskGetSystemUptime to run every 5 ticks * Added support for detecting main disk in cloud version * Added missing import * Finding main device in test * Refactored GetDevices and test to use release_version * Added utils.getIP function, set to run as a 60 tick scheduled task * Added taskEnablePublicDashboard and taskDisablePublicDashboard * Added utils.WriteOption and refactor, added enablePublicDashb0oard * Finalizing online support for dashboard, cloud version support * Added task SetupCloudOptions * Added couple of func description comments * Early return statement (thanks @inverse) * Using IsPublicDashboard in DisablePublicDashboard func * Added constants for release version and device types, added diagnostics.GetReleaseVersion * Removed codecov from test action
44 lines
898 B
Go
44 lines
898 B
Go
// +build unit
|
|
|
|
package storage
|
|
|
|
import (
|
|
"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 or dva device")
|
|
for _, device := range devices {
|
|
|
|
if device.ID == "mmcblk0" || device.ID == "sda" || device.ID == "vda" {
|
|
t.Log("Found target device", device.ID)
|
|
foundDevice = true
|
|
}
|
|
|
|
}
|
|
|
|
if !foundDevice {
|
|
t.Log("Expected to find device mmcblk0, sda or dva but did not. Devices:", devices)
|
|
t.Fail()
|
|
}
|
|
}
|