From: Scott Worley Date: Mon, 27 Jul 2020 21:51:23 +0000 (-0700) Subject: setConfig() helper X-Git-Url: http://git.scottworley.com/syncthing-autoregister/commitdiff_plain/97c3aa62b041338b32fc3755c8ff3483ea1acb9c?ds=sidebyside;hp=80f1294c2d073643352fba816691d816aad4ff44 setConfig() helper --- diff --git a/tests/automatic-enrollment.nix b/tests/automatic-enrollment.nix index 92c90b7..49325fa 100644 --- a/tests/automatic-enrollment.nix +++ b/tests/automatic-enrollment.nix @@ -17,14 +17,15 @@ 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"; @@ -32,15 +33,18 @@ import ({ 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") - machine.copy_from_host( - "${configurationWithDeviceIDs}", - "/etc/nixos/configuration.nix", - ) + setConfig(machine, configurationWithDeviceIDs) machine.succeed( '(( "$(nix eval --raw -f "" config.services.syncthing.declarative.devices.machine.id | wc -c)" == 63 ))' )