From aa6936bb637e46a49cf1292486200ba41dd4bcf7 Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Mon, 3 Nov 2025 21:51:55 -0600 Subject: [PATCH] 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 --- .../yazi/bash-integration-enabled.nix | 20 ++++++----------- .../programs/yazi/zsh-integration-enabled.nix | 22 +++++++------------ 2 files changed, 15 insertions(+), 27 deletions(-) diff --git a/tests/modules/programs/yazi/bash-integration-enabled.nix b/tests/modules/programs/yazi/bash-integration-enabled.nix index 1bebbccad..41f56d765 100644 --- a/tests/modules/programs/yazi/bash-integration-enabled.nix +++ b/tests/modules/programs/yazi/bash-integration-enabled.nix @@ -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"' ''; } diff --git a/tests/modules/programs/yazi/zsh-integration-enabled.nix b/tests/modules/programs/yazi/zsh-integration-enabled.nix index ef8e0ccc8..6087810c5 100644 --- a/tests/modules/programs/yazi/zsh-integration-enabled.nix +++ b/tests/modules/programs/yazi/zsh-integration-enabled.nix @@ -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"' ''; }