]> git.scottworley.com Git - syncthing-autoregister/blob - tests/automatic-enrollment.nix
Enable option for auto-registration
[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 };
15 };
16 environment.systemPackages = with pkgs; [ nix ];
17 }
18 '';
19 in {
20
21 name = "syncthing";
22
23 machine = "${configuration}";
24
25 testScript = ''
26 machine.copy_from_host(
27 "${configuration}",
28 "/etc/nixos/configuration.nix",
29 )
30 machine.wait_for_unit("syncthing-autoregister.service")
31 machine.succeed(
32 '(( "$(nix eval --raw -f /tmp/syncthing-auto-register-test-device-ids.nix services.syncthing.declarative.devices.machine.id | wc -c)" == 63 ))'
33 )
34 '';
35 })