Add SonarQube and unit tests (#22)

This commit was merged in pull request #22.
This commit is contained in:
Luke Tainton
2022-08-13 21:02:15 +01:00
committed by GitHub
parent c4de2f6025
commit d4c812f214
3 changed files with 70 additions and 0 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 == "" {
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()
}
}