ip-checker/api/main_test.go

21 lines
469 B
Go

package main
import (
"testing"
)
func TestInvalidIP(t *testing.T) {
_, err := generateJSON("foo")
errwant := "invalid IP"
if err == nil || err.Error() != errwant {
t.Fatalf(`generateJSON("foo") == "%v", wants "%s"`, err, errwant)
}
}
func TestInaccessibleIP(t *testing.T) {
_, err := generateJSON("0.0.0.0")
errwant := "unspecified IP"
if err == nil || err.Error() != errwant {
t.Fatalf(`generateJSON("0.0.0.0") == "%v", wants "%s"`, err, errwant)
}
}