]> git.scottworley.com Git - syncthing-autoregister/commitdiff
Test reads device ID out of system config
authorScott Worley <scottworley@scottworley.com>
Mon, 27 Jul 2020 21:29:36 +0000 (14:29 -0700)
committerScott Worley <scottworley@scottworley.com>
Mon, 27 Jul 2020 21:29:36 +0000 (14:29 -0700)
tests/automatic-enrollment.nix

index 870e6ee873801927abf0bacb17ac144fe35c3387..92c90b72d0ba90b795061e9907b4d63e6357bc07 100644 (file)
@@ -17,6 +17,14 @@ 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
+        ];
+      }
+    '';
   in {
 
     name = "syncthing";
   in {
 
     name = "syncthing";
@@ -29,8 +37,12 @@ import <nixpkgs/nixos/tests/make-test-python.nix> ({ pkgs, lib, ... }:
           "/etc/nixos/configuration.nix",
       )
       machine.wait_for_unit("syncthing-autoregister.service")
           "/etc/nixos/configuration.nix",
       )
       machine.wait_for_unit("syncthing-autoregister.service")
+      machine.copy_from_host(
+          "${configurationWithDeviceIDs}",
+          "/etc/nixos/configuration.nix",
+      )
       machine.succeed(
       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 ))'
       )
     '';
   })
       )
     '';
   })