From 09e22ae773da92ff7b953d95a022168fe15bab62 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Tue, 26 Jan 2021 20:51:32 -0300 Subject: v0.1.1: Allow names with spaces The test_stdin_is_empty was adapted so it wouldn't exit with status 1. The previous implementation would effectively do: printf '' | grep '' which returns 1, and the test would fail. --- tests/ranking.sh | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'tests/ranking.sh') diff --git a/tests/ranking.sh b/tests/ranking.sh index ea9c2c6..c383b59 100755 --- a/tests/ranking.sh +++ b/tests/ranking.sh @@ -224,13 +224,22 @@ test_stdin_is_empty() { testing 'STDIN is empty' PROFILE="stdin-is-empty-$(uuid)" echo "$BASE_PROFILE" > "$XDG_DATA_HOME/$PROFILE" - INPUT='' - pick_x '' "$INPUT" + OUT="$(mktemp)" + ERR="$(mktemp)" + + printf '' | \ + sh remembering \ + -p "$PROFILE" \ + -c 'tee -a /dev/stderr | head -n1' \ + 1>"$OUT" 2>"$ERR" + + STATUS=$? + assert_status 0 + assert_stdout '' assert_profile "$PROFILE" "$BASE_PROFILE" test_ok } - test_profile_does_not_exist() { testing 'profile does not exist' PROFILE="profile-does-not-exist-$(uuid)" @@ -258,6 +267,18 @@ e' test_ok } +test_names_with_spaces() { + testing 'Names with spaces' + PROFILE="names-with-spaces-$(uuid)" + INPUT='a b c +d e f' + EXPECTED='1:a b c +0:d e f' + pick_x 'a b c' "$INPUT" + assert_profile "$PROFILE" "$EXPECTED" + test_ok +} + test_picking_first_makes_it_be_always_first test_promoting_values test_higher_values_loose_tie @@ -269,3 +290,4 @@ test_stdin_is_smaller_than_profile test_stdin_is_empty test_profile_does_not_exist test_profile_is_empty +test_names_with_spaces -- cgit v1.2.3