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.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748package opensuse
import ( "strings" "testing"
"tangled.org/odd.computer/isomorph/internal/distro")
const primaryXML = `<?xml version="1.0" encoding="UTF-8"?><metadata xmlns="http://linux.duke.edu/metadata/common" xmlns:rpm="http://linux.duke.edu/metadata/rpm" packages="3"><package type="rpm"><name>json-c</name><arch>src</arch><version epoch="0" ver="0.18" rel="1.2"/> <url>https://github.com/json-c/json-c/wiki</url><format><rpm:sourcerpm></rpm:sourcerpm></format></package><package type="rpm"><name>libjson-c5</name><arch>x86_64</arch><version epoch="0" ver="0.18" rel="1.2"/> <url>https://github.com/json-c/json-c/wiki</url><format><rpm:sourcerpm>json-c-0.18-1.2.src.rpm</rpm:sourcerpm></format></package><package type="rpm"><name>at</name><arch>src</arch><version epoch="1" ver="3.2" rel="4"/><url></url><format/></package></metadata>`
func TestParsePrimary(t *testing.T) { got, err := ParsePrimary(strings.NewReader(primaryXML)) if err != nil { t.Fatal(err) } if len(got) != 3 || got[0] != (RPM{Name: "json-c", Arch: "src", Version: "0.18-1.2", URL: "https://github.com/json-c/json-c/wiki"}) || got[1].SourceRPM != "json-c-0.18-1.2.src.rpm" || got[2].Version != "1:3.2-4" { t.Fatalf("ParsePrimary = %+v", got) } for in, want := range map[string]string{"json-c-0.18-1.2.src.rpm": "json-c", "python-foo-bar-1.0-3.1.src.rpm": "python-foo-bar", "x.src.rpm": ""} { if got := SourceName(in); got != want { t.Errorf("SourceName(%q) = %q, want %q", in, got, want) } } if !primaryHrefRe.MatchString(`<data type="primary"><checksum type="sha512">ab</checksum><location href="repodata/x-primary.xml.zst"/></data>`) { t.Error("repomd primary href not found") }}
func TestGitHubPagesHomepage(t *testing.T) { for in, want := range map[string]string{ "https://blueobelisk.github.io/datarepository.html": "https://github.com/blueobelisk/blueobelisk.github.io", "https://foo.github.io/bar/": "https://github.com/foo/bar", } { if got, _, ok := distro.MapHost(in); !ok || got != want { t.Errorf("MapHost(%q) = %q %v, want %q", in, got, ok, want) } }}