dev-cmd/bump: increase test coverage

This commit is contained in:
nandahkrishna 2021-01-25 17:12:43 +05:30
parent 95c6e92d9b
commit 9c914106ed
No known key found for this signature in database
GPG Key ID: 067E5FCD58ADF3AA
2 changed files with 27 additions and 21 deletions

View File

@ -41,18 +41,8 @@ module Homebrew
next
end
current_version = formula.stable.version.to_s
package_data = Repology.single_package_query(formula.name)
repology_latest = if package_data.present?
Repology.latest_version(package_data.values.first)
else
"not found"
end
livecheck_latest = livecheck_result(formula)
pull_requests = retrieve_pull_requests(formula)
display(formula, current_version, repology_latest, livecheck_latest, pull_requests)
retrieve_and_display_info(formula, package_data&.values&.first)
end
else
outdated_packages = Repology.parse_api_response(requested_limit)
@ -71,11 +61,7 @@ module Homebrew
next
end
current_version = formula.stable.version.to_s
repology_latest = Repology.latest_version(repositories)
livecheck_latest = livecheck_result(formula)
pull_requests = retrieve_pull_requests(formula)
display(formula, current_version, repology_latest, livecheck_latest, pull_requests)
retrieve_and_display_info(formula, repositories)
break if requested_limit && i >= requested_limit
end
@ -110,12 +96,18 @@ module Homebrew
pull_requests
end
def up_to_date?(current_version, repology_latest, livecheck_latest)
current_version == repology_latest &&
current_version == livecheck_latest
end
def retrieve_and_display_info(formula, repositories)
current_version = formula.stable.version.to_s
repology_latest = if repositories.present?
Repology.latest_version(repositories)
else
"not found"
end
livecheck_latest = livecheck_result(formula)
pull_requests = retrieve_pull_requests(formula)
def display(formula, current_version, repology_latest, livecheck_latest, pull_requests)
title = if current_version == repology_latest &&
current_version == livecheck_latest
"#{formula} is up to date!"

View File

@ -27,5 +27,19 @@ describe "brew bump" do
.and not_to_output.to_stderr
.and be_a_success
end
it "returns no data and prints a message for HEAD-only formulae" do
content = <<~RUBY
desc "HEAD-only test formula"
homepage "https://brew.sh"
head "https://github.com/Homebrew/brew.git"
RUBY
setup_test_formula("headonly", content)
expect { brew "bump", "headonly" }
.to output(/Formula is HEAD-only./).to_stdout
.and not_to_output.to_stderr
.and be_a_success
end
end
end