Skip to content

Commit

Permalink
test: add a test for tag attr in fetchFromGitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
gepbird committed Dec 23, 2024
1 parent a3599c1 commit c5a2fe3
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/test_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions tests/testpkgs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 { };
Expand Down
13 changes: 13 additions & 0 deletions tests/testpkgs/github-tag.nix
Original file line number Diff line number Diff line change
@@ -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=";
};
}

0 comments on commit c5a2fe3

Please sign in to comment.