Watch
1
0
Fork
You've already forked pkg-proxy
1
mirror of https://github.com/git-pkgs/proxy.git synced 2026-11-09 07:39:19 -05:00
pkg-proxy/internal/mirror/files_test.go
Simon Chrzanowski 749934eb6c Mirror conda packages
A conda version is mirrored with every build anaconda.org lists for it,
each cached under the channel, name, version and subdir/filename the conda
download handler reads from its path. The channel comes from the namespace
or the channel qualifier; a package without one is refused, as retention
keys without one are. The subdir, build and type qualifiers select builds.

Which files a version has, which qualifiers select them and where the
handler caches them is now described per ecosystem, so PyPI and conda share
mirrorFiles.

Part of #414.
2026-10-25 14:27:47 +01:00

38 lines
1.4 KiB
Go

package mirror
import (
"reflect"
"testing"
)
func TestPURLSourceCondaChannelAndQualifiers(t *testing.T) {
versions := &fakeVersions{versions: []string{"1.0", "1.1"}}
source := &PURLSource{
PURLs: []string{
"pkg:conda/conda-forge/numpy@2.1.0?subdir=linux-64&build=py312h_0&type=conda",
"pkg:conda/numpy@2.1.0?channel=conda-forge&repository_url=https://example.com",
"pkg:conda/numpy@2.1.0",
"pkg:conda/numpy",
"pkg:conda/numpy?channel=bioconda&subdir=noarch",
},
Versions: versions,
}
got := enumerate(t, source)
want := []PackageVersion{
{Ecosystem: "conda", Name: "conda-forge/numpy", Version: "2.1.0",
Qualifiers: map[string]string{"subdir": "linux-64", "build": "py312h_0", "type": "conda"}},
{Ecosystem: "conda", Name: "conda-forge/numpy", Version: "2.1.0"},
{Ecosystem: "conda", Name: "numpy", Version: "2.1.0"},
{Ecosystem: "conda", Name: "numpy"},
{Ecosystem: "conda", Name: "bioconda/numpy", Version: "1.0", Qualifiers: map[string]string{"subdir": "noarch"}},
{Ecosystem: "conda", Name: "bioconda/numpy", Version: "1.1", Qualifiers: map[string]string{"subdir": "noarch"}},
}
if !reflect.DeepEqual(got, want) {
t.Errorf("items = %+v\nwant %+v", got, want)
}
if !reflect.DeepEqual(versions.asked, []string{"conda/bioconda/numpy"}) {
t.Errorf("listed versions of %v, want only the package with a channel", versions.asked)
}
}