]> git.scottworley.com Git - syncthing-autoregister/blob - tests/automatic-enrollment.nix
870e6ee873801927abf0bacb17ac144fe35c3387
[syncthing-autoregister] / tests / automatic-enrollment.nix
1 import <nixpkgs/nixos/tests/make-test-python.nix> ({ pkgs, lib, ... }:
2 let
3 configuration = pkgs.writeText "configuration.nix" ''
4 { pkgs, ... }: {
5 imports = [
6 ${../.}/modules/syncthing-autoregister.nix
7 <nixos/nixos/modules/installer/cd-dvd/channel.nix>
8 ];
9 services.syncthing = {
10 enable = true;
11 openDefaultPorts = true;
12 autoRegister = {
13 enable = true;
14 path = "/tmp/syncthing-auto-register-test-device-ids.nix";
15 };
16 };
17 environment.systemPackages = with pkgs; [ nix ];
18 }
19 '';
20 in {
21
22 name = "syncthing";
23
24 machine = "${configuration}";
25
26 testScript = ''
27 machine.copy_from_host(
28 "${configuration}",
29 "/etc/nixos/configuration.nix",
30 )
31 machine.wait_for_unit("syncthing-autoregister.service")
32 machine.succeed(
33 '(( "$(nix eval --raw -f /tmp/syncthing-auto-register-test-device-ids.nix services.syncthing.declarative.devices.machine.id | wc -c)" == 63 ))'
34 )
35 '';
36 })