From c99ea1c2039b57c20bf058184ee77d06f4d78d10 Mon Sep 17 00:00:00 2001 From: Aaron Andersen Date: Wed, 27 Mar 2019 07:35:24 -0400 Subject: [PATCH] nixos/mailcatcher: add nixos test --- nixos/tests/all-tests.nix | 1 + nixos/tests/mailcatcher.nix | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 nixos/tests/mailcatcher.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index a5acf78a8839..49bbe24fdc0e 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -131,6 +131,7 @@ in #lightdm = handleTest ./lightdm.nix {}; login = handleTest ./login.nix {}; #logstash = handleTest ./logstash.nix {}; + mailcatcher = handleTest ./mailcatcher.nix {}; mathics = handleTest ./mathics.nix {}; matrix-synapse = handleTest ./matrix-synapse.nix {}; memcached = handleTest ./memcached.nix {}; diff --git a/nixos/tests/mailcatcher.nix b/nixos/tests/mailcatcher.nix new file mode 100644 index 000000000000..1bed13b23f66 --- /dev/null +++ b/nixos/tests/mailcatcher.nix @@ -0,0 +1,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.json') =~ /this is the body of the email/ or die; + ''; +})