add integration tests for the diff feature

This commit is contained in:
figsoda 2022-11-24 13:05:17 -05:00
parent baf3779e54
commit 8eed06941b
5 changed files with 104 additions and 0 deletions

36
tests/test_github.py Normal file
View File

@ -0,0 +1,36 @@
import subprocess
import conftest
from nix_update import main
def test_main(helpers: conftest.Helpers) -> None:
with helpers.testpkgs(init_git=True) as path:
main(["--file", str(path), "--commit", "github"])
version = subprocess.run(
[
"nix",
"eval",
"--raw",
"--extra-experimental-features",
"nix-command",
"-f",
path,
"github.version",
],
check=True,
text=True,
stdout=subprocess.PIPE,
).stdout.strip()
assert version >= "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

38
tests/test_gitlab.py Normal file
View File

@ -0,0 +1,38 @@
import subprocess
import conftest
from nix_update import main
def test_main(helpers: conftest.Helpers) -> None:
with helpers.testpkgs(init_git=True) as path:
main(["--file", str(path), "--commit", "gitlab"])
version = subprocess.run(
[
"nix",
"eval",
"--raw",
"--extra-experimental-features",
"nix-command",
"-f",
path,
"gitlab.version",
],
check=True,
text=True,
stdout=subprocess.PIPE,
).stdout.strip()
assert version >= "0.22.0"
commit = subprocess.run(
["git", "-C", path, "log", "-1"],
text=True,
stdout=subprocess.PIPE,
check=True,
).stdout.strip()
print(commit)
assert version in commit
assert "gitlab" in commit
assert (
"https://gitlab.gnome.org/world/phosh/phosh/-/compare/v0.20.0...v" in commit
)

View File

@ -1,6 +1,8 @@
{ pkgs ? import <nixpkgs> {} }:
{
crate = pkgs.callPackage ./crate.nix {};
github = pkgs.callPackage ./github.nix {};
gitlab = pkgs.callPackage ./gitlab.nix {};
pypi = pkgs.python3.pkgs.callPackage ./pypi.nix {};
sourcehut = pkgs.python3.pkgs.callPackage ./sourcehut.nix {};
savanna = pkgs.python3.pkgs.callPackage ./savanna.nix {};

13
tests/testpkgs/github.nix Normal file
View File

@ -0,0 +1,13 @@
{ stdenv, fetchFromGitHub }:
stdenv.mkDerivation rec {
pname = "fd";
version = "8.0.0";
src = fetchFromGitHub {
owner = "sharkdp";
repo = pname;
rev = "v${version}";
sha256 = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
};
}

15
tests/testpkgs/gitlab.nix Normal file
View File

@ -0,0 +1,15 @@
{ stdenv, fetchFromGitLab }:
stdenv.mkDerivation rec {
pname = "phosh";
version = "0.20.0";
src = fetchFromGitLab {
domain = "gitlab.gnome.org";
group = "world";
owner = "phosh";
repo = pname;
rev = "v${version}";
sha256 = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
};
}