mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-09 19:13:26 +03:00
nixos/tests/whoami: init
This commit is contained in:
parent
3ae07e6d12
commit
0e02f935b8
3 changed files with 38 additions and 1 deletions
|
@ -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 { };
|
||||
|
|
32
nixos/tests/whoami.nix
Normal file
32
nixos/tests/whoami.nix
Normal file
|
@ -0,0 +1,32 @@
|
|||
{ 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)
|
||||
'';
|
||||
}
|
|
@ -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";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue