about summary refs log tree commit diff
path: root/nixos/tests/mailhog.nix
blob: e3c2da37a3c8a84837ce10e7f7ec7a0a8124af2d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import ./make-test-python.nix ({ lib, ... }: {
  name = "mailhog";
  meta.maintainers = with lib.maintainers; [ jojosch ];

  nodes.machine = { pkgs, ... }: {
    services.mailhog.enable = true;

    environment.systemPackages = with pkgs; [ swaks ];
  };

  testScript = ''
    start_all()

    machine.wait_for_unit("mailhog.service")
    machine.wait_for_open_port(1025)
    machine.wait_for_open_port(8025)
    machine.succeed(
        'echo "this is the body of the email" | swaks --to root@example.org --body - --server localhost:1025'
    )
    assert "this is the body of the email" in machine.succeed(
        "curl --fail http://localhost:8025/api/v2/messages"
    )
  '';
})