package opensuse import ( "context" "testing" ) func TestParseGitURLs(t *testing.T) { m := ParseGitURLs(`2048-cli/2048-cli.spec = https://github.com/tiehuis/2048-cli.git xine-lib/xine-lib.spec = hg::https://hg.code.sf.net/p/xine/xine-lib-1.2 akonadi/akonadi.spec = unknown debug: albert/albert.spec only had https://albertlauncher.github.io/ alac/alac.spec = https://github.com/macosforge/FIXME.git alac multi/a.spec = https://github.com/o/a.git multi/b.spec = https://github.com/o/b.git multi/c.spec = https://github.com/o/a.git `) if len(m) != 3 { t.Fatalf("entries: %v", m) } if got := m["2048-cli"]; len(got) != 1 || got[0] != "https://github.com/tiehuis/2048-cli.git" { t.Errorf("2048-cli: %v", got) } if got := m["xine-lib"]; len(got) != 1 || got[0] != "hg::https://hg.code.sf.net/p/xine/xine-lib-1.2" { t.Errorf("xine-lib: %v", got) } if got := m["multi"]; len(got) != 2 { t.Errorf("multi: %v", got) } if _, ok := m["akonadi"]; ok { t.Error("unknown kept") } if _, ok := m["alac"]; ok { t.Error("FIXME kept") } } func TestLoadGitURLs(t *testing.T) { r := newTestResolver(t) m, err := r.loadGitURLs(context.Background()) if err != nil { t.Fatal(err) } if len(m) != 3 || m["helm"][0] != "https://github.com/helm/helm.git" || m["ceph"][0] != "https://github.com/ceph/ceph.git" { t.Errorf("giturls: %v", m) } // Cached per base URL: a second call must not refetch (same map instance). m2, _ := r.loadGitURLs(context.Background()) if &m2 == nil || len(m2) != len(m) { t.Errorf("cache") } }