1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00

tests/yazi: fix bash/zsh integration tests

Didn't fail even with incorrect assertion. Multi line string for
assertFileContains didn't properly work. Don't want to manage an entire
zsh config file in assertFileContent so just multi step asserting the
generated file.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
Austin Horstman 2025-11-03 21:51:55 -06:00
parent 65bf99c579
commit aa6936bb63
2 changed files with 15 additions and 27 deletions

View file

@ -1,15 +1,3 @@
let
shellIntegration = ''
function yy() {
local tmp="$(mktemp -t "yazi-cwd.XXXXX")"
yazi "$@" --cwd-file="$tmp"
if cwd="$(cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then
builtin cd -- "$cwd"
fi
rm -f -- "$tmp"
}
'';
in
{ {
programs.bash.enable = true; programs.bash.enable = true;
@ -19,6 +7,12 @@ in
}; };
nmt.script = '' nmt.script = ''
assertFileContains home-files/.bashrc '${shellIntegration}' assertFileExists home-files/.bashrc
assertFileContains home-files/.bashrc 'function yy() {'
assertFileContains home-files/.bashrc 'local tmp="$(mktemp -t "yazi-cwd.XXXXX")"'
assertFileContains home-files/.bashrc 'yazi "$@" --cwd-file="$tmp"'
assertFileContains home-files/.bashrc 'if cwd="$(<"$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then'
assertFileContains home-files/.bashrc 'builtin cd -- "$cwd"'
assertFileContains home-files/.bashrc 'rm -f -- "$tmp"'
''; '';
} }

View file

@ -1,24 +1,18 @@
let
shellIntegration = ''
function yy() {
local tmp="$(mktemp -t "yazi-cwd.XXXXX")"
yazi "$@" --cwd-file="$tmp"
if cwd="$(cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then
builtin cd -- "$cwd"
fi
rm -f -- "$tmp"
}
'';
in
{ {
programs.zsh.enable = true; programs.zsh.enable = true;
programs.yazi = { programs.yazi = {
enable = true; enable = true;
enableBashIntegration = true; enableZshIntegration = true;
}; };
nmt.script = '' nmt.script = ''
assertFileContains home-files/.zshrc '${shellIntegration}' assertFileExists home-files/.zshrc
assertFileContains home-files/.zshrc 'function yy() {'
assertFileContains home-files/.zshrc 'local tmp="$(mktemp -t "yazi-cwd.XXXXX")"'
assertFileContains home-files/.zshrc 'yazi "$@" --cwd-file="$tmp"'
assertFileContains home-files/.zshrc 'if cwd="$(<"$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then'
assertFileContains home-files/.zshrc 'builtin cd -- "$cwd"'
assertFileContains home-files/.zshrc 'rm -f -- "$tmp"'
''; '';
} }