Skip to content
quarry Artifact [00f957c366]
Login

Artifact [00f957c366]

Artifact 00f957c3660da39c39f8770dd2b53176836207b7e84f0ec9b013c4363f4d65e7:


package api

import "testing"

// One Fossil repository has many spellings: a default port, a letter
// case or a slash is not a different place, a different path is.
func TestSameFossilRemoteNamesOnePlace(t *testing.T) {
	up := "https://fossil.example.org/quarry"
	for _, same := range []string{
		"https://fossil.example.org/quarry/", "https://FOSSIL.example.org/quarry",
		"https://fossil.example.org:443/quarry", "http://fossil.example.org/quarry",
	} {
		if !sameFossilRemote(same, up) {
			t.Errorf("FAIL: %q reads as a different place from %q", same, up)
		}
	}
	for _, other := range []string{
		"https://fossil.example.org/other", "https://fossil.example.org:8443/quarry",
		"https://other.example.org/quarry", "",
	} {
		if sameFossilRemote(other, up) {
			t.Errorf("FAIL: %q reads as the same place as %q", other, up)
		}
	}
	t.Log("ok")
}

func TestAFossilRemoteBecomesItsWebAddress(t *testing.T) {
	for remote, want := range map[string]string{
		"https://fossil.craftdesign.group/quarry": "fossil.craftdesign.group quarry",
		"https://Fossil.Example.org:8443/a/b/":    "fossil.example.org:8443 a/b",
		"https://fossil.example.org/":             "fossil.example.org ",
	} {
		h, p := fossilPlace(remote)
		if got := h + " " + p; got != want {
			t.Errorf("FAIL: %q -> %q, want %q", remote, got, want)
		}
	}
	t.Log("ok")
}