nixosTests.mailcatcher: migrate to runTest

Part of #386873
This commit is contained in:
Piotr Kwiecinski 2025-03-30 01:24:16 +01:00
parent 1c2f1b30b5
commit 1004fff704
No known key found for this signature in database
GPG key ID: EC0DE1CB9D5258B4
2 changed files with 29 additions and 31 deletions

View file

@ -678,7 +678,7 @@ in {
maestral = handleTest ./maestral.nix {}; maestral = handleTest ./maestral.nix {};
magic-wormhole-mailbox-server = handleTest ./magic-wormhole-mailbox-server.nix {}; magic-wormhole-mailbox-server = handleTest ./magic-wormhole-mailbox-server.nix {};
magnetico = handleTest ./magnetico.nix {}; magnetico = handleTest ./magnetico.nix {};
mailcatcher = handleTest ./mailcatcher.nix {}; mailcatcher = runTest ./mailcatcher.nix;
mailhog = handleTest ./mailhog.nix {}; mailhog = handleTest ./mailhog.nix {};
mailpit = handleTest ./mailpit.nix {}; mailpit = handleTest ./mailpit.nix {};
mailman = handleTest ./mailman.nix {}; mailman = handleTest ./mailman.nix {};

View file

@ -1,37 +1,35 @@
import ./make-test-python.nix ( { lib, ... }:
{ lib, ... }:
{ {
name = "mailcatcher"; name = "mailcatcher";
meta.maintainers = [ lib.maintainers.aanderse ]; meta.maintainers = [ lib.maintainers.aanderse ];
nodes.machine = nodes.machine =
{ pkgs, ... }: { pkgs, ... }:
{ {
services.mailcatcher.enable = true; services.mailcatcher.enable = true;
programs.msmtp = { programs.msmtp = {
enable = true; enable = true;
accounts.default = { accounts.default = {
host = "localhost"; host = "localhost";
port = 1025; port = 1025;
};
}; };
environment.systemPackages = [ pkgs.mailutils ];
}; };
testScript = '' environment.systemPackages = [ pkgs.mailutils ];
start_all() };
machine.wait_for_unit("mailcatcher.service") testScript = ''
machine.wait_for_open_port(1025) start_all()
machine.succeed(
'echo "this is the body of the email" | mail -s "subject" root@example.org' machine.wait_for_unit("mailcatcher.service")
) machine.wait_for_open_port(1025)
assert "this is the body of the email" in machine.succeed( machine.succeed(
"curl -f http://localhost:1080/messages/1.source" '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"
) )
'';
}