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.
12345678910111213141516171819202122232425262728package bulk
import "testing"
func TestPyPIRepo(t *testing.T) { for _, tc := range []struct { name string project string info pypiInfo want string }{ {"homepage on a repo host wins", "p", pypiInfo{HomePage: "https://github.com/o/home", ProjectURLs: map[string]string{"Source": "https://gitlab.com/o/src"}}, "github.com/o/home"}, {"source link, spaces and case folded", "p", pypiInfo{ProjectURLs: map[string]string{"Source Code": "https://gitlab.com/g/sub/p/-/tree/main", "Documentation": "https://docs.example.org"}}, "gitlab.com/g/sub/p"}, {"legacy gitlab route trimmed", "p", pypiInfo{ProjectURLs: map[string]string{"Repository": "https://gitlab.com/g/p/tree/main"}}, "gitlab.com/g/p"}, {"source link on any host", "p", pypiInfo{ProjectURLs: map[string]string{"Source": "https://git.example.org/p.git"}}, "https://git.example.org/p.git"}, {"description mention", "desc", pypiInfo{HomePage: "https://p.readthedocs.io", Description: "Clone https://github.com/o/desc to hack."}, "github.com/o/desc"}, {"sponsors skipped", "real", pypiInfo{ProjectURLs: map[string]string{"Funding": "https://github.com/sponsors/o", "Tracker": "https://github.com/o/real/issues"}}, "github.com/o/real"}, {"nothing", "p", pypiInfo{HomePage: "https://example.org"}, ""}, {"description mention of another project skipped", "python-barbicanclient", pypiInfo{HomePage: "https://docs.openstack.org/python-barbicanclient/latest/", Description: "The server is https://github.com/openstack/barbican; source at https://opendev.org/openstack/python-barbicanclient"}, "opendev.org/openstack/python-barbicanclient"}, {"only other projects in the description", "p", pypiInfo{Description: "Built on https://github.com/o/framework."}, ""}, } { if got := pypiRepo(tc.project, tc.info); got != tc.want { t.Errorf("%s: pypiRepo = %q, want %q", tc.name, got, tc.want) } }}