hyprsunset: Add tests for transitons option

Adds tests to ensure that the services are still created correctly and the correct deprecation warnings are shown

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
kerfuzzle
2025-07-29 10:51:11 +01:00
committed by Austin Horstman
parent 7c01358ff6
commit fa184c5460
2 changed files with 59 additions and 0 deletions

View File

@@ -3,4 +3,5 @@
lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux {
hyprsunset-basic-configuration = ./basic-configuration.nix;
hyprsunset-no-configuration = ./no-configuration.nix;
hyprsunset-transitions-deprecated = ./transitions-deprecated.nix;
}

View File

@@ -0,0 +1,58 @@
{
services.hyprsunset = {
enable = true;
extraArgs = [ "--identity" ];
transitions = {
sunrise = {
calendar = "*-*-* 06:30:00";
requests = [
[ "temperature 6500" ]
[ "identity" ]
];
};
sunset = {
calendar = "*-*-* 19:30:00";
requests = [ [ "temperature 3500" ] ];
};
};
};
nmt.script = ''
# Check that the main service exists
mainService=home-files/.config/systemd/user/hyprsunset.service
assertFileExists $mainService
# Check that the transition services exist
sunriseService=home-files/.config/systemd/user/hyprsunset-sunrise.service
sunsetService=home-files/.config/systemd/user/hyprsunset-sunset.service
assertFileExists $sunriseService
assertFileExists $sunsetService
# Check that the timers exist
sunriseTimer=home-files/.config/systemd/user/hyprsunset-sunrise.timer
sunsetTimer=home-files/.config/systemd/user/hyprsunset-sunset.timer
assertFileExists $sunriseTimer
assertFileExists $sunsetTimer
# Verify timer configurations
assertFileContains $sunriseTimer "OnCalendar=*-*-* 06:30:00"
assertFileContains $sunsetTimer "OnCalendar=*-*-* 19:30:00"
# Verify service configurations
assertFileContains $sunriseService "ExecStart=@hyprland@/bin/hyprctl hyprsunset 'temperature 6500' && @hyprland@/bin/hyprctl hyprsunset identity"
assertFileContains $sunsetService "ExecStart=@hyprland@/bin/hyprctl hyprsunset 'temperature 3500'"
# Check that the config file does not exist
config=home-files/.config/hypr/hyprsunset.conf
assertPathNotExists $config
'';
test.asserts.warnings.expected = [
''
Using services.hyprsunset.transitions is deprecated. Please use
services.hyprsunset.settings instead.
''
];
}