1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-18 11:40:45 +00:00
nixpkgs/nixos/tests/mailpit.nix
Maximilian Bosch 15dab820a6
nixos/mailpit: allow multiple instances
Now it's possible to start multiple mailpit instances - for e.g.
multiple testing environments - on the same machine:

    {
      services.mailpit.instances = {
        dev = { /* ... */ };
        staging = { /* ... */ };
      };
    }

The simplest way to start a single instance is by declaring

    services.mailpit.instances.default = {};
2024-08-14 11:33:52 +02:00

36 lines
988 B
Nix

import ./make-test-python.nix (
{ lib, ... }:
{
name = "mailpit";
meta.maintainers = lib.teams.flyingcircus.members;
nodes.machine =
{ pkgs, ... }:
{
services.mailpit.instances.default = { };
environment.systemPackages = with pkgs; [ swaks ];
};
testScript = ''
start_all()
from json import loads
machine.wait_for_unit("mailpit-default.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'
)
received = loads(machine.succeed("curl http://localhost:8025/api/v1/messages"))
assert received['total'] == 1
message = received["messages"][0]
assert len(message['To']) == 1
assert message['To'][0]['Address'] == 'root@example.org'
assert "this is the body of the email" in message['Snippet']
'';
}
)