-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3008 from mbhall88/main
feat: add crates.io as a source for auto version bump
- Loading branch information
Showing
5 changed files
with
211 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
from unittest.mock import Mock, patch | ||
|
||
import pytest | ||
|
||
from conda_forge_tick.update_sources import CratesIO | ||
|
||
|
||
class TestCratesIOTierDirectory: | ||
def test_four_or_more_characters(self): | ||
pkg = "rasusa" | ||
|
||
actual = CratesIO._tier_directory(pkg) | ||
expected = "ra/su/rasusa" | ||
|
||
assert actual == expected | ||
|
||
def test_four_characters(self): | ||
pkg = "psdm" | ||
|
||
actual = CratesIO._tier_directory(pkg) | ||
expected = "ps/dm/psdm" | ||
|
||
assert actual == expected | ||
|
||
def test_three_characters(self): | ||
pkg = "syn" | ||
|
||
actual = CratesIO._tier_directory(pkg) | ||
expected = "3/s/syn" | ||
|
||
assert actual == expected | ||
|
||
def test_two_characters(self): | ||
pkg = "it" | ||
|
||
actual = CratesIO._tier_directory(pkg) | ||
expected = "2/it" | ||
|
||
assert actual == expected | ||
|
||
def test_one_character(self): | ||
pkg = "a" | ||
|
||
actual = CratesIO._tier_directory(pkg) | ||
expected = "1/a" | ||
|
||
assert actual == expected | ||
|
||
def test_empty_string(self): | ||
pkg = "" | ||
|
||
with pytest.raises(ValueError): | ||
CratesIO._tier_directory(pkg) | ||
|
||
|
||
class TestCratesIOGetVersion: | ||
def test_valid_package(self): | ||
# as far as I can tell, this package has not had a new version in the last 9 | ||
# years, so it should be safe to use for testing as we don't expect the version | ||
# to change | ||
pkg = "gopher" | ||
tier = CratesIO._tier_directory(pkg) | ||
url = f"https://index.crates.io/{tier}" | ||
|
||
actual = CratesIO().get_version(url) | ||
expected = "0.0.3" | ||
|
||
assert actual == expected | ||
|
||
def test_invalid_package(self): | ||
pkg = "shdfbshbvjhbvhsbhsb" | ||
tier = CratesIO._tier_directory(pkg) | ||
url = f"https://index.crates.io/{tier}" | ||
|
||
result = CratesIO().get_version(url) | ||
assert result is None | ||
|
||
@patch("conda_forge_tick.update_sources.requests.get") | ||
def test_empty_package(self, mock_get): | ||
pkg = "syn" | ||
tier = CratesIO._tier_directory(pkg) | ||
url = f"https://index.crates.io/{tier}" | ||
|
||
# Mock response | ||
mock_response = Mock() | ||
mock_response.ok = True | ||
mock_response.text = '{"name": "syn"}' | ||
mock_get.return_value = mock_response | ||
|
||
result = CratesIO().get_version(url) | ||
assert result is None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |