Skip to content
quarry Artifact [be30d52cb4]
Login

Artifact [be30d52cb4]

Artifact be30d52cb45c789a20f062be1671c842ccafa875e3f0bc7cd878a6dbc3ff1c84:


package obs

import "testing"

// The swarm rule counts the pages a crawler asks for that cost the
// forge something: a page named by a hash, and the pages that read a
// repository's whole history (activity, archives, file history, the
// timeline, search). A repository's home or a wiki page is not one.
func TestSwarmPageCoversCostlyPages(t *testing.T) {
	for path, want := range map[string]bool{
		"/r/tcl/checkin/0123456789abcdef/diff":    true,
		"/r/dmestas/sqlite/info/0123456789ab":     true,
		"/r/netbsd-src/activity":                  true,
		"/r/dmestas/netbsd-src/activity":          true,
		"/r/dmestas/pkgsrc/archive/trunk.tar.gz":  true,
		"/r/dmestas/pkgsrc/history/Makefile":      true,
		"/r/dmestas/pkgsrc/timeline":              true,
		"/r/dmestas/pkgsrc/search":                true,
		"/r/dmestas/pkgsrc":                       false,
		"/r/dmestas/pkgsrc/wiki/Home":             false,
		"/r/dmestas/pkgsrc/doc/trunk/activity.md": false,
		"/r/dmestas/pkgsrc/timeline.frag":         false,
	} {
		if got := SwarmPage.MatchString(path); got != want {
			t.Errorf("FAIL: %s matched %v, want %v", path, got, want)
		}
	}
	t.Log("ok")
}