aboutsummaryrefslogtreecommitdiff
path: root/tests/github-flakes.nix
diff options
context:
space:
mode:
Diffstat (limited to 'tests/github-flakes.nix')
-rw-r--r--tests/github-flakes.nix46
1 files changed, 24 insertions, 22 deletions
diff --git a/tests/github-flakes.nix b/tests/github-flakes.nix
index a47610d9a..7ac397d81 100644
--- a/tests/github-flakes.nix
+++ b/tests/github-flakes.nix
@@ -1,6 +1,6 @@
{ nixpkgs, system, overlay }:
-with import (nixpkgs + "/nixos/lib/testing.nix") {
+with import (nixpkgs + "/nixos/lib/testing-python.nix") {
inherit system;
extraConfigurations = [ { nixpkgs.overlays = [ overlay ]; } ];
};
@@ -64,6 +64,7 @@ in
makeTest (
{
+ name = "github-flakes";
nodes =
{ # Impersonate github.com and api.github.com.
@@ -113,36 +114,37 @@ makeTest (
};
};
- testScript = { nodes }:
- ''
- use POSIX qw(strftime);
-
- startAll;
+ testScript = { nodes }: ''
+ # fmt: off
+ import json
+ import time
- $github->waitForUnit("httpd.service");
+ start_all()
- $client->succeed("curl -v https://github.com/ >&2");
+ github.wait_for_unit("httpd.service")
- $client->succeed("nix registry list | grep nixpkgs");
+ client.succeed("curl -v https://github.com/ >&2")
+ client.succeed("nix registry list | grep nixpkgs")
- $client->succeed("nix flake info nixpkgs --json | jq -r .revision") eq "${nixpkgs.rev}\n"
- or die "revision mismatch";
+ rev = client.succeed("nix flake info nixpkgs --json | jq -r .revision")
+ assert rev.strip() == "${nixpkgs.rev}", "revision mismatch"
- $client->succeed("nix registry pin nixpkgs");
+ client.succeed("nix registry pin nixpkgs")
- $client->succeed("nix flake info nixpkgs --tarball-ttl 0 >&2");
+ client.succeed("nix flake info nixpkgs --tarball-ttl 0 >&2")
- # Shut down the web server. The flake should be cached on the client.
- $github->succeed("systemctl stop httpd.service");
+ # Shut down the web server. The flake should be cached on the client.
+ github.succeed("systemctl stop httpd.service")
- my $date = $client->succeed("nix flake info nixpkgs --json | jq -M .lastModified");
- strftime("%Y%m%d%H%M%S", gmtime($date)) eq "${nixpkgs.lastModifiedDate}" or die "time mismatch";
+ info = json.loads(client.succeed("nix flake info nixpkgs --json"))
+ date = time.strftime("%Y%m%d%H%M%S", time.gmtime(info['lastModified']))
+ assert date == "${nixpkgs.lastModifiedDate}", "time mismatch"
- $client->succeed("nix build nixpkgs#hello");
+ client.succeed("nix build nixpkgs#hello")
- # The build shouldn't fail even with --tarball-ttl 0 (the server
- # being down should not be a fatal error).
- $client->succeed("nix build nixpkgs#fuse --tarball-ttl 0");
- '';
+ # The build shouldn't fail even with --tarball-ttl 0 (the server
+ # being down should not be a fatal error).
+ client.succeed("nix build nixpkgs#fuse --tarball-ttl 0")
+ '';
})