aboutsummaryrefslogtreecommitdiff
path: root/tests/github-flakes.nix
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2020-12-20 14:02:12 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2020-12-20 14:02:12 +0000
commitbd96403da6a1181e46a52be7befade0c00f9e743 (patch)
tree0f66b119acd03c11e2cad776087889b7827261dc /tests/github-flakes.nix
parentbdc772022766e65fa8ea6d29fff0735529ab47f3 (diff)
parentec3e20283216374c15843c403363a890221d3fcb (diff)
Merge remote-tracking branch 'upstream/master' into trustless-remote-builder-simple
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")
+ '';
})