https://git.jolheiser.com/nixery-nix.git
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
{ pkgs, nixeryModule }: let port = 8888; portStr = builtins.toString port; user = "test"; group = "tester"; in pkgs.testers.nixosTest { name = "nixery-service-test"; nodes.machine = { config, pkgs, ... }: { imports = [ nixeryModule ]; services.nixery = { enable = true; inherit port user group; }; systemd.services.nixery.serviceConfig.TimeoutStartSec = "5min"; }; testScript = '' start_all() machine.wait_for_unit("multi-user.target") machine.wait_for_unit("nixery.service") machine.wait_for_open_port(${portStr}) machine.succeed("systemctl is-active nixery.service") machine.succeed("curl -f http://localhost:${portStr}/v2/") machine.succeed("id ${user}") machine.succeed("getent group ${group}") machine.succeed("test -d /var/lib/nixery") machine.succeed("stat -c '%U:%G' /var/lib/nixery | grep '${user}:${group}'") machine.wait_for_unit("docker.service") machine.succeed("docker info") # Requires network connection to pull from nix cache # machine.succeed("docker pull localhost:8080/shell/hello") ''; }