added barebones tests for system package

main
KeeganForelight 2 years ago
parent 9392892ede
commit 72fe309a25

@ -4,9 +4,38 @@ import (
"testing" "testing"
) )
// TestGetInfo ensures that the array can be populated with device info.
func TestGetInfo(t *testing.T) { func TestGetInfo(t *testing.T) {
info, err := GetInfo() if err := getInfo(); err != nil {
if err != nil { t.Fatalf(`getInfo() failed %v`, err)
panic(err)
} }
} }
// TestGetIP tests that the IP is returned without error and not empty.
func TestGetIP(t *testing.T) {
if ip, err := GetIP(); err != nil || ip == "" {
t.Fatalf(`GetIP() failed, got %s, err: %v`, ip, err)
}
}
// TestGetID tests that the ID is returned without error and not empty.
func TestGetID(t *testing.T) {
if id, err := GetID(); err != nil || id == 0 {
t.Fatalf(`GetID() failed, got %d %v`, id, err)
}
}
// TestGetModel tests that the Model is returned without error and not empty.
func TestGetModel(t *testing.T) {
if model, err := GetModel(); err != nil || model == "" {
t.Fatalf(`GetModel() failed, got %s %v`, model, err)
}
}
// TestGetModel tests that the correct error is thrown as the bus does not exist on the test rig.
func TestGetBus(t *testing.T) {
if bus, err := GetBus(); err != ErrBusNotFound {
t.Fatalf(`GetBus() should fail, got %d %v`, bus, err)
}
}

Loading…
Cancel
Save