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.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960package opensuse
import ( "context" "errors" "reflect" "testing")
func TestOBSPackageCandidates(t *testing.T) { pkgs := map[string]bool{"adios2": true, "curl": true, "python-foo": true} for src, want := range map[string][]string{ "curl": {"curl"}, "curl-mini": {"curl"}, "adios2-openmpi4": {"adios2"}, "python-foo-doc": {"python-foo"}, "libfoo": nil, "python-foo-bar-x": {"python-foo"}, } { if got := OBSPackageCandidates(src, pkgs); !reflect.DeepEqual(got, want) { t.Errorf("%s: %v, want %v", src, got, want) } }}
func TestOBSFiles(t *testing.T) { r := newTestResolver(t) ctx := context.Background() pkgs := map[string]bool{"apr": true, "curl": true, "helm": true}
if _, err := r.OBSFiles(ctx, "helm", []string{"helm"}, false); !errors.Is(err, ErrNotCached) { t.Fatalf("cache-only before fetching: %v", err) } helm, err := r.OBSFiles(ctx, "helm", OBSPackageCandidates("helm", pkgs), true) if err != nil || helm == nil || helm.SpecName != "helm.spec" || len(helm.Spec) == 0 || len(helm.Service) == 0 { t.Fatalf("helm: %+v %v", helm, err) } // Now cached: no network needed. if f, err := r.OBSFiles(ctx, "helm", []string{"helm"}, false); err != nil || f == nil { t.Fatalf("cache-only after fetching: %+v %v", f, err) } // A multibuild flavour's source package is built from the base package's spec. mini, err := r.OBSFiles(ctx, "curl-mini", OBSPackageCandidates("curl-mini", pkgs), true) if err != nil || mini == nil || mini.Package != "curl" || mini.SpecName != "curl.spec" || mini.Service != nil { t.Fatalf("curl-mini: %+v %v", mini, err) }
// The _service's obs_scm URL decides helm; apr's comes from its spec's Source0. if c := Candidates("https://github.com/helm/helm", nil, helm); len(c) == 0 || c[0].Key != "github.com/helm/helm" || c[0].Evidence[0].Source != "_service:obs_scm:url" { t.Errorf("helm candidates: %+v", c) } apr, err := r.OBSFiles(ctx, "apr", []string{"apr"}, true) if err != nil || apr == nil { t.Fatalf("apr: %v", err) } if c := Candidates("https://apr.apache.org/", nil, apr); len(c) == 0 || c[0].Key != "github.com/apache/apr" { t.Errorf("apr candidates: %+v", c) }}