Skip to content
quarry Artifact [6b6a609306]
Login

Artifact [6b6a609306]

Artifact 6b6a60930619b5d7a1c5834de9fea9aa2e8519f28418b24cca43937cac8baac1:


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)
		}
	}
}