1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-16 16:19:44 +01:00
home-manager/tests/modules/programs/borgmatic/include-hm-symlinks.nix

46 lines
1 KiB
Nix
Raw Normal View History

{ config, pkgs, ... }:
let
2023-05-13 00:08:12 +02:00
backups = config.programs.borgmatic.backups;
2023-05-13 00:08:12 +02:00
excludeFile = builtins.toFile "excludeFile.txt" "/foo/bar";
in {
2023-05-13 00:08:12 +02:00
programs.borgmatic = {
enable = true;
backups = {
main = {
location = {
sourceDirectories = [ "/my-stuff-to-backup" ];
repositories = [ "/mnt/disk1" ];
excludeHomeManagerSymlinks = false;
extraConfig = { exclude_from = [ (toString excludeFile) ]; };
};
};
};
2023-05-13 00:08:12 +02:00
};
2023-05-13 00:08:12 +02:00
test.stubs.borgmatic = { };
2023-05-13 00:08:12 +02:00
nmt.script = ''
config_file=$TESTED/home-files/.config/borgmatic.d/main.yaml
assertFileExists $config_file
2023-05-13 00:08:12 +02:00
declare -A expectations
2023-05-13 00:08:12 +02:00
expectations[location.exclude_from[0]]="${excludeFile}"
2023-05-13 00:08:12 +02:00
yq=${pkgs.yq-go}/bin/yq
2023-05-13 00:08:12 +02:00
for filter in "''${!expectations[@]}"; do
expected_value="''${expectations[$filter]}"
actual_value="$($yq ".$filter" $config_file)"
2023-05-13 00:08:12 +02:00
if [[ "$actual_value" != "$expected_value" ]]; then
fail "Expected '$filter' to be '$expected_value' but was '$actual_value'"
fi
done
2023-05-13 00:08:12 +02:00
'';
}