Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev-cmd/bump: increase test coverage #10417

Merged
merged 1 commit into from Jan 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 13 additions & 21 deletions Library/Homebrew/dev-cmd/bump.rb
Expand Up @@ -41,18 +41,8 @@ def bump
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)
Expand All @@ -71,11 +61,7 @@ def bump
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
Expand Down Expand Up @@ -110,12 +96,18 @@ def retrieve_pull_requests(formula)
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!"
Expand Down
14 changes: 14 additions & 0 deletions Library/Homebrew/test/dev-cmd/bump_spec.rb
Expand Up @@ -27,5 +27,19 @@
.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