Skip to content

Commit

Permalink
Expand #checkable_urls test coverage
Browse files Browse the repository at this point in the history
This expands tests for `#checkable_urls` to cover everything except
branches that shouldn't ever be reached.
  • Loading branch information
samford committed Oct 25, 2024
1 parent eb7ef6e commit 12ccae8
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions Library/Homebrew/test/livecheck/livecheck_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@
end
end

let(:f_stable_url_only) do
stable_url_s = stable_url

formula("test_no_checkable_urls") do
desc "Test livecheck URL formula with only a stable URL"
url stable_url_s
end
end

let(:r) { f.resources.first }

let(:c) do
Expand All @@ -56,6 +65,17 @@
RUBY
end

let(:c_no_checkable_urls) do
Cask::CaskLoader.load(+<<-RUBY)
cask "test_no_checkable_urls" do
version "0.0.1,2"
name "Test"
desc "Test Livecheck URL cask"
end
RUBY
end

describe "::resolve_livecheck_reference" do
context "when a formula/cask has a livecheck block without formula/cask methods" do
it "returns [nil, []]" do
Expand Down Expand Up @@ -134,15 +154,6 @@
end
end

let(:f_stable_url_only) do
stable_url_s = stable_url

formula("test_no_checkable_urls") do
desc "Test livecheck URL formula with only a stable URL"
url stable_url_s
end
end

let(:r_livecheck_url) { f_livecheck_url.resources.first }

let(:c_livecheck_url) do
Expand All @@ -158,17 +169,6 @@
RUBY
end

let(:c_no_checkable_urls) do
Cask::CaskLoader.load(+<<-RUBY)
cask "test_no_checkable_urls" do
version "0.0.1,2"
name "Test"
desc "Test Livecheck URL cask"
end
RUBY
end

it "returns a URL string when given a livecheck_url string for a formula" do
expect(livecheck.livecheck_url_to_string(livecheck_url, f_livecheck_url)).to eq(livecheck_url)
end
Expand Down Expand Up @@ -222,6 +222,8 @@
expect(livecheck.checkable_urls(c)).to eq([cask_url, homepage_url])
expect(livecheck.checkable_urls(r)).to eq([resource_url])
expect(livecheck.checkable_urls(f_duplicate_urls)).to eq([stable_url, head_url])
expect(livecheck.checkable_urls(f_stable_url_only)).to eq([stable_url])
expect(livecheck.checkable_urls(c_no_checkable_urls)).to eq([])
end
end

Expand Down

0 comments on commit 12ccae8

Please sign in to comment.