package main
import "testing"
// A forge that does not know its own public address cannot check what
// readers receive, and health.New skips a dep with no URL — so "" is
// how the check turns itself off rather than probing something wrong.
func TestTheOriginCheckIsSkippedWithoutAPublicAddress(t *testing.T) {
for _, in := range []string{"", " "} {
if got := originCheckURL(in); got != "" {
t.Errorf("FAIL: originCheckURL(%q) = %q, want empty", in, got)
}
}
}
// One slash, however the operator wrote the origin.
func TestTheOriginCheckBuildsOneCleanURL(t *testing.T) {
for _, tc := range []struct{ in, want string }{
{"https://zeitforge.app", "https://zeitforge.app/"},
{"https://zeitforge.app/", "https://zeitforge.app/"},
{" https://zeitforge.app/ ", "https://zeitforge.app/"},
{"http://127.0.0.1:8950", "http://127.0.0.1:8950/"},
} {
if got := originCheckURL(tc.in); got != tc.want {
t.Errorf("FAIL: originCheckURL(%q) = %q, want %q", tc.in, got, tc.want)
}
}
}