nixos/tests/syncthing: add defaults test
This commit is contained in:
@@ -1585,6 +1585,7 @@ in
|
||||
sx = runTest ./sx.nix;
|
||||
sympa = runTest ./sympa.nix;
|
||||
syncthing = runTest ./syncthing/main.nix;
|
||||
syncthing-defaults = runTest ./syncthing/defaults.nix;
|
||||
syncthing-folders = runTest ./syncthing/folders.nix;
|
||||
syncthing-guiPassword = runTest ./syncthing/guiPassword.nix;
|
||||
syncthing-guiPasswordFile = runTest ./syncthing/guiPasswordFile.nix;
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
{ lib, pkgs, ... }:
|
||||
let
|
||||
expectedPath = "/tmp/syncthing-default";
|
||||
in
|
||||
{
|
||||
name = "syncthing-defaults";
|
||||
meta.maintainers = with pkgs.lib.maintainers; [ seudonym ];
|
||||
|
||||
nodes.machine =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
environment.systemPackages = [
|
||||
pkgs.libxml2
|
||||
pkgs.curl
|
||||
];
|
||||
services.syncthing = {
|
||||
enable = true;
|
||||
settings.defaults.folder.path = expectedPath;
|
||||
};
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
import json
|
||||
|
||||
machine.wait_for_unit("syncthing.service")
|
||||
machine.wait_for_unit("syncthing-init.service")
|
||||
|
||||
# Get the API key by parsing the config.xml
|
||||
api_key = machine.succeed(
|
||||
"xmllint --xpath 'string(configuration/gui/apikey)' /var/lib/syncthing/.config/syncthing/config.xml"
|
||||
).strip()
|
||||
|
||||
# Query the defaults/folder endpoint via Syncthing's REST API
|
||||
config = json.loads(machine.succeed(
|
||||
f"curl -Ssf -H 'X-API-Key: {api_key}' http://127.0.0.1:8384/rest/config/defaults/folder"
|
||||
))
|
||||
|
||||
actual_path = config.get('path')
|
||||
assert actual_path == "${expectedPath}", f"Default folder path is '{actual_path}', but expected '${expectedPath}'"
|
||||
machine.log(f"Success: Default folder path is correctly set to '{actual_path}'")
|
||||
'';
|
||||
}
|
||||
Reference in New Issue
Block a user