From e4f474a8df2b704781d9cbe35aa5a45b59cf6f98 Mon Sep 17 00:00:00 2001
From: Jean-Paul Calderone <exarkun@twistedmatrix.com>
Date: Wed, 7 Aug 2019 11:10:34 -0400
Subject: [PATCH] start of a whole-system automated test for the module

---
 nixos/modules/private-storage.nix       |  6 ++++--
 nixos/modules/tests/private-storage.nix | 20 ++++++++++++++++++++
 2 files changed, 24 insertions(+), 2 deletions(-)
 create mode 100644 nixos/modules/tests/private-storage.nix

diff --git a/nixos/modules/private-storage.nix b/nixos/modules/private-storage.nix
index c8258769..eab06650 100644
--- a/nixos/modules/private-storage.nix
+++ b/nixos/modules/private-storage.nix
@@ -35,11 +35,13 @@ in
     };
   };
   config = lib.mkIf cfg.enable
-  { services.tahoe.nodes."alpha" =
+  { services.tahoe.nodes."storage" =
     { package = config.services.private-storage.tahoe.package;
       sections =
       { node =
-        { nickname = "alpha";
+        # XXX Should try to name that is unique across the grid.
+        { nickname = "storage";
+          web.port = "tcp:3456:interface=127.0.0.1";
         };
         storage =
         { enabled = true;
diff --git a/nixos/modules/tests/private-storage.nix b/nixos/modules/tests/private-storage.nix
new file mode 100644
index 00000000..048646a1
--- /dev/null
+++ b/nixos/modules/tests/private-storage.nix
@@ -0,0 +1,20 @@
+# https://nixos.org/nixos/manual/index.html#sec-nixos-tests
+import <nixpkgs/nixos/tests/make-test.nix> {
+
+  # Configure a single machine as a PrivateStorage storage node.
+  machine =
+    { config, pkgs, ... }:
+    { imports =
+      [ ../private-storage.nix
+      ];
+      services.private-storage.enable = true;
+    };
+
+  # Test the machine with a Perl program (sobbing).
+  testScript =
+    ''
+      $machine->start;
+      $machine->waitForUnit("tahoe.storage.service");
+      $machine->succeed("tahoe -d /var/db/tahoe-lafs/storage status");
+    '';
+}
-- 
GitLab