Something went wrong. Try again.
Maps Linux distribution source packages to their upstream repositories, and through them to each other
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263package bulk
import ( "testing"
"tangled.org/odd.computer/isomorph/internal/model")
func TestNamedLike(t *testing.T) { for _, c := range []struct { pkg, key string want bool }{ {"curl", "github.com/curl/curl", true}, {"trurl", "github.com/curl/curl", false}, {"binutils-djgpp", "git.savannah.gnu.org/binutils", true}, {"rust1.88", "github.com/rust-lang/rust", true}, {"llvm-toolchain-19", "github.com/llvm/llvm-project", true}, {"lit", "github.com/llvm/llvm-project", false}, {"python-sphinxcontrib-jsmath", "github.com/sphinx-doc/sphinx", false}, {"python3-sphinx", "github.com/sphinx-doc/sphinx", true}, {"lziprecover", "git.savannah.gnu.org/lzip", false}, {"python310", "github.com/python/cpython", true}, {"python-zope.configuration", "github.com/python/cpython", false}, {"apache2", "github.com/apache/httpd", true}, {"gpg2", "git.gnupg.org/gnupg", true}, {"gpgme", "git.gnupg.org/gnupg", false}, {"go", "go.googlesource.com/go", true}, } { if got := namedLike(c.pkg, c.key); got != c.want { t.Errorf("namedLike(%q, %q) = %v", c.pkg, c.key, got) } }}
// TestSiteOnlyGuard: a project site cannot hand its repository to another package, but a// forge homepage or a source URL still can.func TestSiteOnlyGuard(t *testing.T) { ev := func(src, val, key string, w float64) model.Evidence { return model.Evidence{Source: src, Value: val, Key: key, Weight: w} } trurl := Package{Name: "trurl", Evidence: []model.Evidence{ev("spec:URL", "https://curl.se/trurl", "github.com/curl/curl", 0.3)}} Rescore(&trurl, nil) if trurl.UpstreamKey != "" { t.Errorf("trurl took curl's repository from curl.se: %+v", trurl) } curl := Package{Name: "curl", Evidence: []model.Evidence{ev("spec:URL", "https://curl.se/", "github.com/curl/curl", 0.3)}} Rescore(&curl, nil) if curl.UpstreamKey != "github.com/curl/curl" { t.Errorf("curl lost its own site: %+v", curl) } forge := Package{Name: "trurl", Evidence: []model.Evidence{ev("spec:URL", "https://github.com/curl/trurl", "github.com/curl/trurl", 0.5)}} Rescore(&forge, nil) if forge.UpstreamKey != "github.com/curl/trurl" { t.Errorf("a forge homepage must still count: %+v", forge) } src := Package{Name: "lzlib", Evidence: []model.Evidence{ev("debian/watch:upstream_url", "https://download.savannah.gnu.org/releases/lzip/lzlib/lzlib-1.16.tar.lz", "git.savannah.gnu.org/lzip", 0.36)}} Rescore(&src, nil) if src.UpstreamKey != "git.savannah.gnu.org/lzip" { t.Errorf("a source URL is not a site hint: %+v", src) }}