X-Git-Url: http://git.scottworley.com/syncthing-autoregister/blobdiff_plain/7fb0951bc9caf6bd5cf71439638beea3499a0acc..cefa20b6ac66bfe7793f6ded33a7eb9e2354379f:/tests/automatic-enrollment.nix?ds=sidebyside diff --git a/tests/automatic-enrollment.nix b/tests/automatic-enrollment.nix index 9577510..4694048 100644 --- a/tests/automatic-enrollment.nix +++ b/tests/automatic-enrollment.nix @@ -11,25 +11,45 @@ import ({ pkgs, lib, ... }: openDefaultPorts = true; autoRegister = { enable = true; + path = "/tmp/syncthing-auto-register-test-device-ids.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"; - machine = "${configuration}"; + nodes = { + a = "${configuration}"; + b = "${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}" ) - 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 ))' + + setConfig(a, initialConfiguration) + a.wait_for_unit("syncthing-autoregister.service") + setConfig(a, configurationWithDeviceIDs) + a.succeed( + '(( "$(nix eval --raw -f "" config.services.syncthing.declarative.devices.a.id | wc -c)" == 63 ))' ) ''; })