summaryrefslogtreecommitdiffstats
path: root/nixos/tests/merecat.nix
blob: db790dff41e8bfbdcf4313ac01203fb4265c9bb9 (plain)
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
{ pkgs, ... }:
{
  name = "merecat";
  meta = with pkgs.lib.maintainers; {
    maintainers = [ fgaz ];
  };

  nodes.machine =
    { config, pkgs, ... }:
    {
      services.merecat = {
        enable = true;
        settings = {
          hostname = "localhost";
          virtual-host = true;
          directory = toString (
            pkgs.runCommand "merecat-webdir" { } ''
              mkdir -p $out/foo.localhost $out/bar.localhost
              echo '<h1>Hello foo</h1>' > $out/foo.localhost/index.html
              echo '<h1>Hello bar</h1>' > $out/bar.localhost/index.html
            ''
          );
        };
      };
    };

  testScript = ''
    machine.wait_for_unit("merecat")
    machine.wait_for_open_port(80)
    machine.succeed("curl --fail foo.localhost | grep 'Hello foo'")
    machine.succeed("curl --fail bar.localhost | grep 'Hello bar'")
  '';
}