about summary refs log tree commit diff
path: root/nixos/tests/mailcatcher.nix
blob: 627ef56617e9bc5604760fb71ba9f9baf05dc438 (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
25
26
27
28
29
30
31
32
33
34
35
import ./make-test-python.nix ({ lib, ... }:

{
  name = "mailcatcher";
  meta.maintainers = [ lib.maintainers.aanderse ];

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

      programs.msmtp = {
        enable = true;
        accounts.default = {
          host = "localhost";
          port = 1025;
        };
      };

      environment.systemPackages = [ pkgs.mailutils ];
    };

  testScript = ''
    start_all()

    machine.wait_for_unit("mailcatcher.service")
    machine.wait_for_open_port(1025)
    machine.succeed(
        'echo "this is the body of the email" | mail -s "subject" root@example.org'
    )
    assert "this is the body of the email" in machine.succeed(
        "curl -f http://localhost:1080/messages/1.source"
    )
  '';
})