about summary refs log tree commit diff
path: root/nixpkgs/nixos/tests/mailcatcher.nix
blob: d45b5d4edfc504bd586b364b518aa88685a8e1ba (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
import ./make-test.nix ({ lib, ... }:

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

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

      networking.defaultMailServer.directDelivery = true;
      networking.defaultMailServer.hostName = "localhost:1025";

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

  testScript = ''
    startAll;

    $machine->waitForUnit('mailcatcher.service');
    $machine->waitForOpenPort('1025');
    $machine->succeed('echo "this is the body of the email" | mail -s "subject" root@example.org');
    $machine->succeed('curl http://localhost:1080/messages/1.source') =~ /this is the body of the email/ or die;
  '';
})