mirror of
https://github.com/CodelyTV/pr-size-labeler.git
synced 2025-02-18 19:12:50 -05:00
* Support ignore deletions with "ignore_file_deletions" param Test files_to_ignore code path Tweak the variable type Correct bad logic in the file ignore block Debug More debugging More debugging Fingers crossed Another try Last try Lets see if this one does it Testing again More tests More testing Last test Wait, I might be onto something Put some changes back Fixes Whoops Walk back yml test * Rename config variable to be ignore_line_deletions * Add and update tests * Update action.yml to provided more consistent desc. Co-authored-by: Javier Ferrer González <javier.mailserio@gmail.com> * Delete redundant helper function * Fix parse error in action.yml --------- Co-authored-by: Javier Ferrer González <javier.mailserio@gmail.com>
43 lines
No EOL
1.4 KiB
Bash
43 lines
No EOL
1.4 KiB
Bash
#!/bin/bash
|
|
|
|
function set_up() {
|
|
source ./src/misc.sh
|
|
source ./src/github.sh
|
|
}
|
|
|
|
pr_number=123
|
|
files_to_ignore=''
|
|
ignore_line_deletions='false'
|
|
|
|
function test_should_count_changes() {
|
|
mock curl cat ./tests/fixtures/pull_request_api
|
|
|
|
assert_match_snapshot "$(github::calculate_total_modifications "$pr_number" "${files_to_ignore[*]}" "$ignore_line_deletions")"
|
|
}
|
|
|
|
function test_should_count_changes_ignore_deletions() {
|
|
ignore_line_deletions='true'
|
|
|
|
mock curl cat ./tests/fixtures/pull_request_api
|
|
|
|
assert_match_snapshot "$(github::calculate_total_modifications "$pr_number" "${files_to_ignore[*]}" "$ignore_line_deletions")"
|
|
}
|
|
|
|
# NOTE: when `files_to_ignore` is set, we have to invoke the PR files API and iterate each file
|
|
# one at at time. This is why the mock call is diffent in the subsequent test cases
|
|
function test_should_ignore_files_with_glob() {
|
|
files_to_ignore=("*.lock" ".editorconfig")
|
|
|
|
mock curl cat ./tests/fixtures/pull_request_files_api
|
|
|
|
assert_match_snapshot "$(github::calculate_total_modifications "$pr_number" "${files_to_ignore[*]}" "$ignore_line_deletions")"
|
|
}
|
|
|
|
function test_should_ignore_files_with_glob_ignore_deletions() {
|
|
files_to_ignore=("*.lock" ".editorconfig")
|
|
ignore_line_deletions='true'
|
|
|
|
mock curl cat ./tests/fixtures/pull_request_files_api
|
|
|
|
assert_match_snapshot "$(github::calculate_total_modifications "$pr_number" "${files_to_ignore[*]}" "$ignore_line_deletions")"
|
|
} |