X-Git-Url: http://git.scottworley.com/syncthing-autoregister/blobdiff_plain/aaeffc92aa6bf5a33cc56e7ee41d15ccaf240b2a..b00b144bd77fdaca30cb490e78e06e41617a79ad:/tests/automatic-enrollment.nix?ds=sidebyside diff --git a/tests/automatic-enrollment.nix b/tests/automatic-enrollment.nix new file mode 100644 index 0000000..cac1b28 --- /dev/null +++ b/tests/automatic-enrollment.nix @@ -0,0 +1,32 @@ +import ({ pkgs, lib, ... }: + let + configuration = pkgs.writeText "configuration.nix" '' + { pkgs, ... }: { + imports = [ + ${../.}/modules/syncthing-autoregister.nix + + ]; + services.syncthing = { + enable = true; + openDefaultPorts = true; + }; + environment.systemPackages = with pkgs; [ nix ]; + } + ''; + in { + + name = "syncthing"; + + machine = "${configuration}"; + + testScript = '' + machine.copy_from_host( + "${configuration}", + "/etc/nixos/configuration.nix", + ) + 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 ))' + ) + ''; + })