Skip to content

Commit

Permalink
chore: make sure output file is created
Browse files Browse the repository at this point in the history
  • Loading branch information
y3owk1n committed Jan 6, 2024
1 parent 7266846 commit 7f7a929
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tests/_test_fzf_cmd_history.fish
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ set output_file $temp_dir/output.txt

# Test _fzf_cmd_history without options
setup_mocked_history
$output_file <(echo "command1" | _fzf_cmd_history)
echo command1 | _fzf_cmd_history >$output_file

set selected_command_without_equals (string replace '=' '' (cat $output_file))
@test "selected command is correct" "$selected_command_without_equals" = command1

# Test _fzf_cmd_history with custom prompt name
setup_mocked_history
setup_mocked_fzf
output_file <(echo "command2" | _fzf_cmd_history --prompt-name "CustomPrompt")
echo command2 | _fzf_cmd_history --prompt-name CustomPrompt >$output_file

set selected_command_without_equals (string replace '=' '' (cat $output_file))
@test "selected command is correct with custom prompt name" "$selected_command_without_equals" = command2
Expand All @@ -41,7 +41,7 @@ set selected_command_without_equals (string replace '=' '' (cat $output_file))
# Test _fzf_cmd_history with allow-execute option
setup_mocked_history
setup_mocked_fzf
$output_file <(echo "command3" | _fzf_cmd_history --allow-execute)
echo command3 | _fzf_cmd_history --allow-execute >$output_file

set selected_command_without_equals (string replace '=' '' (cat $output_file))
@test "selected command is correct with allow-execute option" "$selected_command_without_equals" = command3
Expand All @@ -50,15 +50,15 @@ set selected_command_without_equals (string replace '=' '' (cat $output_file))
# Test _fzf_cmd_history with both prompt name and allow-execute options
setup_mocked_history
setup_mocked_fzf
$output_file <(echo "command4" | _fzf_cmd_history --prompt-name "CustomPrompt" --allow-execute)
echo command4 | _fzf_cmd_history --prompt-name CustomPrompt --allow-execute >$output_file

set selected_command_without_equals (string replace '=' '' (cat $output_file))
@test "selected command is correct with both options" "$selected_command_without_equals" = command4
@test "prompt name in fzf is correct" $FZF_PROMPT_NAME = CustomPrompt

# Test _fzf_cmd_history with allow-execute option (execution validation)
setup_mocked_history
$output_file <(echo "command5" | _fzf_cmd_history --allow-execute)
echo command5 | _fzf_cmd_history --allow-execute >$output_file
eval (cat $output_file)
@test "command execution with allow-execute is successful" $status -eq 0

Expand Down

0 comments on commit 7f7a929

Please sign in to comment.