]>
Commit | Line | Data |
---|---|---|
b00b144b SW |
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; | |
7fb0951b SW |
12 | autoRegister = { |
13 | enable = true; | |
64eaba73 | 14 | path = "/tmp/syncthing-auto-register-test-device-ids.nix"; |
7fb0951b | 15 | }; |
b00b144b SW |
16 | }; |
17 | environment.systemPackages = with pkgs; [ nix ]; | |
18 | } | |
19 | ''; | |
80f1294c SW |
20 | configurationWithDeviceIDs = pkgs.writeText "configuration-with-device-ids.nix" '' |
21 | { | |
22 | imports = [ | |
23 | ${configuration} | |
24 | /tmp/syncthing-auto-register-test-device-ids.nix | |
25 | ]; | |
26 | } | |
27 | ''; | |
b00b144b SW |
28 | in { |
29 | ||
30 | name = "syncthing"; | |
31 | ||
32 | machine = "${configuration}"; | |
33 | ||
34 | testScript = '' | |
35 | machine.copy_from_host( | |
36 | "${configuration}", | |
37 | "/etc/nixos/configuration.nix", | |
38 | ) | |
39 | machine.wait_for_unit("syncthing-autoregister.service") | |
80f1294c SW |
40 | machine.copy_from_host( |
41 | "${configurationWithDeviceIDs}", | |
42 | "/etc/nixos/configuration.nix", | |
43 | ) | |
b00b144b | 44 | machine.succeed( |
80f1294c | 45 | '(( "$(nix eval --raw -f "<nixos/nixos>" config.services.syncthing.declarative.devices.machine.id | wc -c)" == 63 ))' |
b00b144b SW |
46 | ) |
47 | ''; | |
48 | }) |