X-Git-Url: http://git.scottworley.com/syncthing-autoregister/blobdiff_plain/80f1294c2d073643352fba816691d816aad4ff44..0a262b7925af942e617dd75bc531ec9d96836608:/tests/automatic-enrollment.nix diff --git a/tests/automatic-enrollment.nix b/tests/automatic-enrollment.nix index 92c90b7..8cbcdc4 100644 --- a/tests/automatic-enrollment.nix +++ b/tests/automatic-enrollment.nix @@ -17,32 +17,44 @@ import ({ 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 - ]; - } - ''; + 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", - ) - machine.wait_for_unit("syncthing-autoregister.service") - machine.copy_from_host( - "${configurationWithDeviceIDs}", - "/etc/nixos/configuration.nix", - ) - machine.succeed( - '(( "$(nix eval --raw -f "" config.services.syncthing.declarative.devices.machine.id | wc -c)" == 63 ))' + def setConfig(machine, config): + machine.copy_from_host(config, "/etc/nixos/configuration.nix") + + + def verifyDeviceIDSet(machine, expectedDevice): + machine.succeed( + '(( "$(nix eval --raw -f "" config.services.syncthing.declarative.devices.%s.id | wc -c)" == 63 ))' + % expectedDevice + ) + + + initialConfiguration = "${configuration}" + configurationWithDeviceIDs = ( + "${configurationWithDeviceIDs}" ) + + setConfig(a, initialConfiguration) + a.wait_for_unit("syncthing-autoregister.service") + setConfig(a, configurationWithDeviceIDs) + verifyDeviceIDSet(a, "a") ''; })