Add test cases

This commit is contained in:
2022-08-13 20:54:38 +01:00
parent e1997cbca1
commit aa3c0c74f3
2 changed files with 37 additions and 3 deletions

29
ipilot_test.go Normal file
View File

@@ -0,0 +1,29 @@
package main
import "testing"
func TestGetCurrentIP(t *testing.T) {
myip := getLocalIP()
if myip == nil {
t.Log("could not retrieve current IP")
t.Fail()
}
}
func TestIsIPAddress(t *testing.T) {
ipaddress := "192.168.0.1"
isIP := isIPAddress(ipaddress)
if isIP == false {
t.Log("could not verify " + ipaddress + " is an IP address")
t.Fail()
}
}
func TestResolveDNSHostname(t *testing.T) {
hostname := "one.one.one.one"
ipaddress := resolveDNSHostname(hostname)
if ipaddress != "1.1.1.1" {
t.Log("could not resolve IP for " + hostname)
t.Fail()
}
}