Unverified Commit 0e02f935 authored by Defelo's avatar Defelo
Browse files

nixos/tests/whoami: init

parent 3ae07e6d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1445,6 +1445,7 @@ in
  webhook = runTest ./webhook.nix;
  weblate = handleTest ./web-apps/weblate.nix { };
  whisparr = handleTest ./whisparr.nix { };
  whoami = runTest ./whoami.nix;
  whoogle-search = handleTest ./whoogle-search.nix { };
  wiki-js = runTest ./wiki-js.nix;
  wine = handleTest ./wine.nix { };

nixos/tests/whoami.nix

0 → 100644
+32 −0
Original line number Diff line number Diff line
{ lib, ... }:

{
  name = "echoip";
  meta.maintainers = with lib.maintainers; [ defelo ];

  nodes.machine = {
    services.whoami.enable = true;
  };

  interactive.nodes.machine = {
    networking.firewall.allowedTCPPorts = [ 8000 ];
    virtualisation.forwardPorts = [
      {
        from = "host";
        host.port = 8000;
        guest.port = 8000;
      }
    ];
  };

  testScript = ''
    import re

    machine.wait_for_unit("whoami.service")
    machine.wait_for_open_port(8000)

    response = machine.succeed("curl -H 'X-Test-Header: Hello World!' http://127.0.0.1:8000/test")
    assert re.search(r"^GET /test", response, re.M)
    assert re.search(r"^X-Test-Header: Hello World!", response, re.M)
  '';
}
+5 −1
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
  lib,
  buildGoModule,
  fetchFromGitHub,
  nixosTests,
  nix-update-script,
}:

@@ -31,7 +32,10 @@ buildGoModule (finalAttrs: {
    runHook postInstallCheck
  '';

  passthru.updateScript = nix-update-script { };
  passthru = {
    tests = { inherit (nixosTests) whoami; };
    updateScript = nix-update-script { };
  };

  meta = {
    description = "Tiny Go server that prints os information and HTTP request to output";