]> git.scottworley.com Git - syncthing-autoregister/blobdiff - tests/automatic-enrollment.nix
setConfig() helper
[syncthing-autoregister] / tests / automatic-enrollment.nix
index 870e6ee873801927abf0bacb17ac144fe35c3387..49325fa90e5f71d19270683c93f0964087b978fb 100644 (file)
@@ -17,6 +17,15 @@ import <nixpkgs/nixos/tests/make-test-python.nix> ({ pkgs, lib, ... }:
         environment.systemPackages = with pkgs; [ nix ];
       }
     '';
+    configurationWithDeviceIDs =
+      pkgs.writeText "configuration-with-device-ids.nix" ''
+        {
+          imports = [
+            ${configuration}
+            /tmp/syncthing-auto-register-test-device-ids.nix
+          ];
+        }
+      '';
   in {
 
     name = "syncthing";
@@ -24,13 +33,20 @@ import <nixpkgs/nixos/tests/make-test-python.nix> ({ pkgs, lib, ... }:
     machine = "${configuration}";
 
     testScript = ''
-      machine.copy_from_host(
-          "${configuration}",
-          "/etc/nixos/configuration.nix",
+      def setConfig(machine, config):
+          machine.copy_from_host(config, "/etc/nixos/configuration.nix")
+
+
+      initialConfiguration = "${configuration}"
+      configurationWithDeviceIDs = (
+          "${configurationWithDeviceIDs}"
       )
+
+      setConfig(machine, initialConfiguration)
       machine.wait_for_unit("syncthing-autoregister.service")
+      setConfig(machine, configurationWithDeviceIDs)
       machine.succeed(
-          '(( "$(nix eval --raw -f /tmp/syncthing-auto-register-test-device-ids.nix services.syncthing.declarative.devices.machine.id | wc -c)" == 63 ))'
+          '(( "$(nix eval --raw -f "<nixos/nixos>" config.services.syncthing.declarative.devices.machine.id | wc -c)" == 63 ))'
       )
     '';
   })