mirror of
https://github.com/nix-community/home-manager.git
synced 2026-01-12 01:50:44 +08: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:
@@ -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;
|
||||
|
||||
@@ -19,6 +7,12 @@ in
|
||||
};
|
||||
|
||||
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"'
|
||||
'';
|
||||
}
|
||||
|
||||
@@ -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.yazi = {
|
||||
enable = true;
|
||||
enableBashIntegration = true;
|
||||
enableZshIntegration = true;
|
||||
};
|
||||
|
||||
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"'
|
||||
'';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user