Skip to content

Commit

Permalink
Fix assert_result arguments order
Browse files Browse the repository at this point in the history
Co-authored-by: Olivier Halligon <olivier.halligon@automattic.com>
  • Loading branch information
iangmaia and AliSoftware authored Feb 21, 2025
1 parent ace4813 commit 10481bb
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions tests/pr_changed_files/test_any_match_patterns.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,42 +39,42 @@ assert_result $result 0 "$output" "true" "Should match .swift files with --stdou
# [Test] Match multiple patterns - exit code only
output=$(pr_changed_files --any-match 'docs/*.md' '*.rb')
result=$?
assert_result 0 $result "$output" "" "Should match multiple patterns"
assert_result $result 0 "$output" "" "Should match multiple patterns"

# Test with stdout
output=$(pr_changed_files --stdout --any-match 'docs/*.md' '*.rb')
result=$?
assert_result 0 $result "$output" "true" "Should match multiple patterns with --stdout"
assert_result $result 0 "$output" "true" "Should match multiple patterns with --stdout"

# [Test] Match files with spaces and special characters - exit code only
output=$(pr_changed_files --any-match 'docs/read me.md' 'docs/special!@*#$chars.md')
result=$?
assert_result 0 $result "$output" "" "Should match files with spaces and special characters"
assert_result $result 0 "$output" "" "Should match files with spaces and special characters"

# Test with stdout
output=$(pr_changed_files --stdout --any-match 'docs/read me.md' 'docs/special!@*#$chars.md')
result=$?
assert_result 0 $result "$output" "true" "Should match files with spaces and special characters with --stdout"
assert_result $result 0 "$output" "true" "Should match files with spaces and special characters with --stdout"

# [Test] No matches - exit code only
output=$(pr_changed_files --any-match '*.js')
result=$?
assert_result 1 $result "$output" "" "Should not match non-existent patterns"
assert_result $result 1 "$output" "" "Should not match non-existent patterns"

# Test with stdout
output=$(pr_changed_files --stdout --any-match '*.js')
result=$?
assert_result 0 $result "$output" "false" "Should not match non-existent patterns with --stdout"
assert_result $result 0 "$output" "false" "Should not match non-existent patterns with --stdout"

# [Test] Directory pattern - exit code only
output=$(pr_changed_files --any-match 'docs/*')
result=$?
assert_result 0 $result "$output" "" "Should match directory patterns"
assert_result $result 0 "$output" "" "Should match directory patterns"

# Test with stdout
output=$(pr_changed_files --stdout --any-match 'docs/*')
result=$?
assert_result 0 $result "$output" "true" "Should match directory patterns with --stdout"
assert_result $result 0 "$output" "true" "Should match directory patterns with --stdout"

# [Test] Exact pattern matching - exit code only
echo "swiftfile" > swiftfile.txt
Expand All @@ -83,11 +83,11 @@ git commit -m "Add file with swift in name"

output=$(pr_changed_files --any-match '*.swift')
result=$?
assert_result 0 $result "$output" "" "Should only match exact patterns"
assert_result $result 0 "$output" "" "Should only match exact patterns"

# Test with stdout
output=$(pr_changed_files --stdout --any-match '*.swift')
result=$?
assert_result 0 $result "$output" "true" "Should only match exact patterns with --stdout"
assert_result $result 0 "$output" "true" "Should only match exact patterns with --stdout"

echo "✅ Any-match pattern tests passed"

0 comments on commit 10481bb

Please sign in to comment.