Skip to content
quarry Artifact [d524549e68]
Login

Artifact [d524549e68]

Artifact d524549e68375579646fa0ffa12c95e6a07b6fbce3ee43b07da728cc07d0ad3c:


package web

import "testing"

// Repo was read with req.PathValue in the outermost middleware, where
// the router has not set it: path values live on the request the mux
// passes DOWN, a copy that middleware never sees. Every render recorded
// before this carried an empty repo — 61 of 61 rows in the analytics
// store — which made every number unattributable on a fleet where
// repository size is the dominant cost.
func TestRepoOfPath(t *testing.T) {
	for path, want := range map[string]string{
		"/r/pikchr":                  "pikchr",
		"/r/pikchr/":                 "pikchr",
		"/r/fossil/timeline":         "fossil",
		"/r/fossil/checkin/abc123":   "fossil",
		"/r/spatialite%2Dtools/docs": "spatialite-tools", // the router would unescape it
		"/fleet":                     "",
		"/fleet/ops":                 "",
		"/":                          "",
		"":                           "",
		"/r/":                        "",
	} {
		if got := repoOfPath(path); got != want {
			t.Errorf("repoOfPath(%q) = %q, want %q", path, got, want)
		}
	}
}