From f0d24b431c1ee1a829be6163dd749e1b373ea5a3 Mon Sep 17 00:00:00 2001 From: Michael Hall Date: Thu, 26 Sep 2024 10:03:37 +1000 Subject: [PATCH] test: add full test for crates.io source --- tests/test_upstream_versions.py | 35 +++++++++++++++++++++++++ tests/test_yaml/version_wbg-rand.yaml | 37 +++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 tests/test_yaml/version_wbg-rand.yaml diff --git a/tests/test_upstream_versions.py b/tests/test_upstream_versions.py index 6115f520a..1bc587db6 100644 --- a/tests/test_upstream_versions.py +++ b/tests/test_upstream_versions.py @@ -17,6 +17,7 @@ NPM, NVIDIA, AbstractSource, + CratesIO, Github, GithubReleases, PyPI, @@ -1719,3 +1720,37 @@ def test_github_releases(tmpdir, url, feedstock_version): ghr = GithubReleases() url = ghr.get_url(meta_yaml) assert VersionOrder(ghr.get_version(url)) > VersionOrder(feedstock_version) + + +def test_latest_version_cratesio(tmpdir): + name = "wbg-rand" + recipe_path = os.path.join(YAML_PATH, "version_wbg-rand.yaml") + curr_ver = "0.4.0" + ver = "0.4.1" + source = CratesIO() + + with open(recipe_path) as fd: + inp = fd.read() + + pmy = LazyJson(os.path.join(str(tmpdir), "cf-scripts-test.json")) + with pmy as _pmy: + yml = parse_meta_yaml(inp) + _pmy.update(yml["source"]) + _pmy.update( + { + "feedstock_name": name, + "version": curr_ver, + "raw_meta_yaml": inp, + "meta_yaml": yml, + }, + ) + + attempt = get_latest_version(name, pmy, [source], use_container=False) + if ver is None: + assert attempt["new_version"] is not False + assert attempt["new_version"] != curr_ver + assert VersionOrder(attempt["new_version"]) > VersionOrder(curr_ver) + elif ver is False: + assert attempt["new_version"] is ver + else: + assert ver == attempt["new_version"] diff --git a/tests/test_yaml/version_wbg-rand.yaml b/tests/test_yaml/version_wbg-rand.yaml new file mode 100644 index 000000000..064dbb1ff --- /dev/null +++ b/tests/test_yaml/version_wbg-rand.yaml @@ -0,0 +1,37 @@ +package: + name: wbg-rand + version: "0.4.0" + +source: + url: https://crates.io/api/v1/crates/wbg-rand/0.4.0/download + fn: "wbg-rand-0.4.0.tar.gz" + sha256: 5505e10cb191f56fed835c35baf4ac97b5466148a13fbcaeb1173198b1a52b4c + +build: + number: 0 + skip: true # [win] + +requirements: + build: + - {{ compiler('rust') }} + - {{ compiler('c') }} + - {{ stdlib("c") }} + - cargo-bundle-licenses + +test: + commands: + - echo "This is a placeholder for the test section" + +about: + home: https://github.com/alexcrichton/wbg-rand + summary: 'Random numbers for wasm32-unknown-unknown in Rust' + description: | + Implementation of rand for wasm32-unknown-unknown in Rust using #[wasm_bindgen]. + license: MIT AND Apache-2.0 + license_file: + - LICENSE-MIT + - LICENSE-APACHE + +extra: + recipe-maintainers: + - mbhall88 \ No newline at end of file