Skip to content

Commit

Permalink
fix(tests): replace [[ with [
Browse files Browse the repository at this point in the history
  • Loading branch information
Ninzalo committed Nov 2, 2024
1 parent 68adc06 commit 2cce142
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion tests/test_check_colorscheme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ check_tmux_option() {
local expected_value=$2
local actual_value
actual_value=$(tmux show-option -gqv $option)
if [[ "$actual_value" == "$expected_value" ]]; then
if [ "$actual_value" == "$expected_value" ]; then
echo "PASS: $option is set correctly to $expected_value"
else
echo "FAIL: $option is $actual_value, expected $expected_value"
Expand Down
8 changes: 4 additions & 4 deletions tests/test_e2e1_custom_widgets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ generate_expected_output() {
local add_separator="${3:-true}"

for i in $( seq 1 $(($param_count + 1)) ); do
if [[ "$i" -ne $(($param_count + 1)) ]]; then
if [ "$i" -ne $(($param_count + 1)) ]; then
echo "$i" >> "$file"
echo "#ffffff" >> "$file"
echo "#000000" >> "$file"
fi

if [[ "$i" -eq $(($param_count + 1)) ]]; then
if [ "$i" -eq $(($param_count + 1)) ]; then
echo "" >> "$file"
echo "" >> "$file"
echo "" >> "$file"
fi
done

if [[ "$add_separator" == true ]]; then
if [ "$add_separator" == true ]; then
echo "---" >> "$file"
fi
}
Expand All @@ -52,7 +52,7 @@ log_tmux_messages() {
tmux display-message -p "#{E:@tmst-$prefix-p${i}-bg}" >> "$log_file"
done

if [[ "$add_separator" == true ]]; then
if [ "$add_separator" == true ]; then
echo "---" >> "$log_file"
fi
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test_parse_widgets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ check_tmux_option() {
local expected_value=$2
local actual_value
actual_value=$(tmux show-option -gqv $option)
if [[ "$actual_value" == "$expected_value" ]]; then
if [ "$actual_value" == "$expected_value" ]; then
echo "PASS: $option is set correctly to [$expected_value]"
else
echo "FAIL: $option is [$actual_value], expected [$expected_value]"
Expand Down
12 changes: 6 additions & 6 deletions tests/test_set_widget_options.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ check_tmux_option() {
local expected_value=$2
local actual_value
actual_value=$(tmux show-option -gqv "$option")
if [[ "$actual_value" == "$expected_value" ]]; then
if [ "$actual_value" == "$expected_value" ]; then
echo "PASS: $option is set correctly to $expected_value"
else
echo "FAIL: $option is $actual_value, expected $expected_value"
Expand Down Expand Up @@ -49,7 +49,7 @@ done
# Check the widget format for 3 parts
EXPECTED_FORMAT=$(build_expected_format "$PARTS_AMOUNT")
actual_format=$(tmux show-option -gqv "$ORIGINAL_WIDGET")
if [[ "$actual_format" == "$EXPECTED_FORMAT" ]]; then
if [ "$actual_format" == "$EXPECTED_FORMAT" ]; then
echo "PASS: Widget format for $PARTS_AMOUNT parts is set correctly to $EXPECTED_FORMAT"
else
echo "FAIL: $ORIGINAL_WIDGET is $actual_format, expected $EXPECTED_FORMAT"
Expand All @@ -76,7 +76,7 @@ done
# Check the widget format for 1 part
EXPECTED_FORMAT=$(build_expected_format "$PARTS_AMOUNT")
actual_format=$(tmux show-option -gqv "$ORIGINAL_WIDGET")
if [[ "$actual_format" == "$EXPECTED_FORMAT" ]]; then
if [ "$actual_format" == "$EXPECTED_FORMAT" ]; then
echo "PASS: Widget format for $PARTS_AMOUNT part is set correctly to $EXPECTED_FORMAT"
else
echo "FAIL: $ORIGINAL_WIDGET is $actual_format, expected $EXPECTED_FORMAT"
Expand All @@ -103,7 +103,7 @@ done
# Check the widget format for 20 parts
EXPECTED_FORMAT=$(build_expected_format "$PARTS_AMOUNT")
actual_format=$(tmux show-option -gqv "$ORIGINAL_WIDGET")
if [[ "$actual_format" == "$EXPECTED_FORMAT" ]]; then
if [ "$actual_format" == "$EXPECTED_FORMAT" ]; then
echo "PASS: Widget format for $PARTS_AMOUNT parts is set correctly to $EXPECTED_FORMAT"
else
echo "FAIL: $ORIGINAL_WIDGET is $actual_format, expected $EXPECTED_FORMAT"
Expand All @@ -120,7 +120,7 @@ ORIGINAL_WIDGET="@${PLUGIN_NAME}-${WIDGET_NAME}-${PARTS_AMOUNT}-widget"

# Run the script and expect it to fail
bash "$CURRENT_FILE/utils/set_widget_options.sh" "$PLUGIN_NAME" "$WIDGET_NAME" "$PARTS_AMOUNT" "$ORIGINAL_WIDGET"
if [[ $? -ne 0 ]]; then
if [ $? -ne 0 ]; then
echo "PASS: Test for PARTS_AMOUNT=0 failed as expected"
else
echo "FAIL: Test for PARTS_AMOUNT=0 should have failed"
Expand All @@ -137,7 +137,7 @@ ORIGINAL_WIDGET="@${PLUGIN_NAME}-${WIDGET_NAME}-${PARTS_AMOUNT}-widget"

# Run the script and expect it to fail
bash "$CURRENT_FILE/utils/set_widget_options.sh" "$PLUGIN_NAME" "$WIDGET_NAME" "$PARTS_AMOUNT" "$ORIGINAL_WIDGET"
if [[ $? -ne 0 ]]; then
if [ $? -ne 0 ]; then
echo "PASS: Test for PARTS_AMOUNT=21 failed as expected"
else
echo "FAIL: Test for PARTS_AMOUNT=21 should have failed"
Expand Down

0 comments on commit 2cce142

Please sign in to comment.