]> git.scottworley.com Git - syncthing-autoregister/blobdiff - tests/automatic-enrollment.nix
Syncthing device-id autoregistration
[syncthing-autoregister] / tests / automatic-enrollment.nix
diff --git a/tests/automatic-enrollment.nix b/tests/automatic-enrollment.nix
new file mode 100644 (file)
index 0000000..cac1b28
--- /dev/null
@@ -0,0 +1,32 @@
+import <nixpkgs/nixos/tests/make-test-python.nix> ({ pkgs, lib, ... }:
+  let
+    configuration = pkgs.writeText "configuration.nix" ''
+      { pkgs, ... }: {
+        imports = [
+          ${../.}/modules/syncthing-autoregister.nix
+          <nixos/nixos/modules/installer/cd-dvd/channel.nix>
+        ];
+        services.syncthing = {
+          enable = true;
+          openDefaultPorts = true;
+        };
+        environment.systemPackages = with pkgs; [ nix ];
+      }
+    '';
+  in {
+
+    name = "syncthing";
+
+    machine = "${configuration}";
+
+    testScript = ''
+      machine.copy_from_host(
+          "${configuration}",
+          "/etc/nixos/configuration.nix",
+      )
+      machine.wait_for_unit("syncthing-autoregister.service")
+      machine.succeed(
+          '(( "$(nix eval --raw -f /tmp/syncthing-auto-register-test-device-ids.nix services.syncthing.declarative.devices.machine.id | wc -c)" == 63 ))'
+      )
+    '';
+  })