]> git.scottworley.com Git - syncthing-autoregister/commitdiff
setConfig() helper
authorScott Worley <scottworley@scottworley.com>
Mon, 27 Jul 2020 21:51:23 +0000 (14:51 -0700)
committerScott Worley <scottworley@scottworley.com>
Mon, 27 Jul 2020 21:59:29 +0000 (14:59 -0700)
tests/automatic-enrollment.nix

index 92c90b72d0ba90b795061e9907b4d63e6357bc07..49325fa90e5f71d19270683c93f0964087b978fb 100644 (file)
@@ -17,14 +17,15 @@ import <nixpkgs/nixos/tests/make-test-python.nix> ({ pkgs, lib, ... }:
         environment.systemPackages = with pkgs; [ nix ];
       }
     '';
         environment.systemPackages = with pkgs; [ nix ];
       }
     '';
-    configurationWithDeviceIDs = pkgs.writeText "configuration-with-device-ids.nix" ''
-      {
-        imports = [
-          ${configuration}
-          /tmp/syncthing-auto-register-test-device-ids.nix
-        ];
-      }
-    '';
+    configurationWithDeviceIDs =
+      pkgs.writeText "configuration-with-device-ids.nix" ''
+        {
+          imports = [
+            ${configuration}
+            /tmp/syncthing-auto-register-test-device-ids.nix
+          ];
+        }
+      '';
   in {
 
     name = "syncthing";
   in {
 
     name = "syncthing";
@@ -32,15 +33,18 @@ import <nixpkgs/nixos/tests/make-test-python.nix> ({ pkgs, lib, ... }:
     machine = "${configuration}";
 
     testScript = ''
     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")
       machine.wait_for_unit("syncthing-autoregister.service")
-      machine.copy_from_host(
-          "${configurationWithDeviceIDs}",
-          "/etc/nixos/configuration.nix",
-      )
+      setConfig(machine, configurationWithDeviceIDs)
       machine.succeed(
           '(( "$(nix eval --raw -f "<nixos/nixos>" config.services.syncthing.declarative.devices.machine.id | wc -c)" == 63 ))'
       )
       machine.succeed(
           '(( "$(nix eval --raw -f "<nixos/nixos>" config.services.syncthing.declarative.devices.machine.id | wc -c)" == 63 ))'
       )