diff --git a/tests/test_github.py b/tests/test_github.py index 3a39c46..f55e799 100644 --- a/tests/test_github.py +++ b/tests/test_github.py @@ -78,6 +78,39 @@ def test_github_empty_fallback(helpers: conftest.Helpers) -> None: ) +def test_github_tag(helpers: conftest.Helpers) -> None: + with helpers.testpkgs(init_git=True) as path: + monkeypatch = pytest.MonkeyPatch() + monkeypatch.setenv("GITHUB_TOKEN", "invalid_token") + main(["--file", str(path), "--commit", "github-tag"]) + version = subprocess.run( + [ + "nix", + "eval", + "--raw", + "--extra-experimental-features", + "nix-command", + "-f", + path, + "github-tag.version", + ], + check=True, + text=True, + stdout=subprocess.PIPE, + ).stdout.strip() + assert tuple(map(int, version.split("."))) >= (8, 5, 2) + commit = subprocess.run( + ["git", "-C", path, "log", "-1"], + text=True, + stdout=subprocess.PIPE, + check=True, + ).stdout.strip() + print(commit) + assert version in commit + assert "github" in commit + assert "https://github.com/sharkdp/fd/compare/v8.0.0...v" in commit + + def test_github_feed_fallback(helpers: conftest.Helpers) -> None: with helpers.testpkgs(init_git=True) as path: monkeypatch = pytest.MonkeyPatch() diff --git a/tests/testpkgs/default.nix b/tests/testpkgs/default.nix index 1a798f6..d1dc90f 100644 --- a/tests/testpkgs/default.nix +++ b/tests/testpkgs/default.nix @@ -21,6 +21,7 @@ gitea = pkgs.callPackage ./gitea.nix { }; github = pkgs.callPackage ./github.nix { }; github-no-release = pkgs.callPackage ./github-no-release.nix { }; + github-tag = pkgs.callPackage ./github-tag.nix { }; gitlab = pkgs.callPackage ./gitlab.nix { }; pypi = pkgs.python3.pkgs.callPackage ./pypi.nix { }; sourcehut = pkgs.python3.pkgs.callPackage ./sourcehut.nix { }; diff --git a/tests/testpkgs/github-tag.nix b/tests/testpkgs/github-tag.nix new file mode 100644 index 0000000..4eb593b --- /dev/null +++ b/tests/testpkgs/github-tag.nix @@ -0,0 +1,13 @@ +{ stdenv, fetchFromGitHub }: + +stdenv.mkDerivation rec { + pname = "fd"; + version = "8.0.0"; + + src = fetchFromGitHub { + owner = "sharkdp"; + repo = pname; + tag = "v${version}"; + sha256 = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; + }; +}