github.com/iDigitalFlame/xmt@v0.5.4/device/local/local_test.go (about) 1 // Copyright (C) 2020 - 2023 iDigitalFlame 2 // 3 // This program is free software: you can redistribute it and/or modify 4 // it under the terms of the GNU General Public License as published by 5 // the Free Software Foundation, either version 3 of the License, or 6 // any later version. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU General Public License for more details. 12 // 13 // You should have received a copy of the GNU General Public License 14 // along with this program. If not, see <https://www.gnu.org/licenses/>. 15 // 16 17 package local 18 19 import "testing" 20 21 func TestLocal(t *testing.T) { 22 if Device.ID.Empty() { 23 t.Fatalf("Local Device ID should not be empty!") 24 } 25 if len(Device.Hostname) == 0 { 26 t.Fatalf("Local Device Hostname should not be empty!") 27 } 28 if len(Device.User) == 0 { 29 t.Fatalf("Local Device User should not be empty!") 30 } 31 if len(Device.Version) == 0 { 32 t.Fatalf("Local Device Version should not be empty!") 33 } 34 if Device.PID == 0 { 35 t.Fatalf("Local Device PID should not be zero!") 36 } 37 if Device.PPID == 0 { 38 t.Fatalf("Local Device PPID should not be zero!") 39 } 40 for i := range Device.Network { 41 if Device.Network[i].Mac == 0 { 42 t.Fatalf("Local Device Interface %s MAC address should not be empty!", Device.Network[i].Name) 43 } 44 for x := range Device.Network[i].Address { 45 if Device.Network[i].Address[x].IsUnspecified() { 46 t.Fatalf("Local Device Interface %s IP address %d should not be zero!", Device.Network[i].Name, x) 47 } 48 } 49 } 50 }