about summary refs log tree commit diff
path: root/nixpkgs/nixos/tests/mailcatcher.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/nixos/tests/mailcatcher.nix')
-rw-r--r--nixpkgs/nixos/tests/mailcatcher.nix26
1 files changed, 26 insertions, 0 deletions
diff --git a/nixpkgs/nixos/tests/mailcatcher.nix b/nixpkgs/nixos/tests/mailcatcher.nix
new file mode 100644
index 000000000000..d45b5d4edfc5
--- /dev/null
+++ b/nixpkgs/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.source') =~ /this is the body of the email/ or die;
+  '';
+})