package devices_test import ( "fmt" "testing" "gitea.mmo.to/ppForge/ppforge/devices" ) func TestListDevices(t *testing.T) { list, err := devices.List() if err != nil { fmt.Println("Got error: ", err) t.Fail() } fmt.Printf("%s", list) lo_in_list := false for _, e := range list { if e == "lo" { lo_in_list = true } } if !lo_in_list { t.Fail() } } func TestGetHardwareAddress(t *testing.T) { list, err := devices.List() if err != nil { fmt.Println("Got error: ", err) t.Fail() } fmt.Printf("%s", list) hwaddr, err := devices.GetHardwareAddress(list[1]) fmt.Println("Hardware address: ", hwaddr) if hwaddr == "" || err != nil { // might have catched lo ? fmt.Println("catched 'lo'? or error: ", err) t.Fail() } } func TestGetAddresses(t *testing.T) { list, err := devices.List() if err != nil { fmt.Println("Got error: ", err) t.Fail() } fmt.Printf("%s", list) addrlist, err := devices.GetAddresses(list[1]) fmt.Println("Addresses: ", addrlist) if len(addrlist) == 0 || err != nil { fmt.Println("Addrlist empty? or error: ", err) t.Fail() } }