Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Library/Homebrew/cask/audit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -806,8 +806,13 @@ def audit_livecheck_version
)
if result
throttle = cask.livecheck.throttle
throttle ||= referenced_cask.livecheck.throttle if referenced_cask
latest_version = throttle ? result[:latest_throttled] : result[:latest]
throttle_days = cask.livecheck.throttle_days
if referenced_cask
throttle ||= referenced_cask.livecheck.throttle
throttle_days ||= referenced_cask.livecheck.throttle_days
end

latest_version = (throttle || throttle_days) ? result[:latest_throttled] : result[:latest]
Comment thread
samford marked this conversation as resolved.
end

if latest_version && (cask.version.to_s == latest_version.to_s)
Expand Down
83 changes: 83 additions & 0 deletions Library/Homebrew/test/cask/audit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,37 @@ def tmp_cask(name, text)
end
end

context "when the Cask has a `livecheck` block using `throttle days:`" do
let(:cask_token) { "livecheck-throttle-days" }
let(:cask) do
tmp_cask cask_token.to_s, <<~RUBY
cask "#{cask_token}" do
version "1.2.5"
sha256 "8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b"

url "https://brew.sh/#{cask_token}-1.2.5.dmg"
name "Throttle Days"
homepage "https://brew.sh/#{cask_token}"

livecheck do
url :homepage
throttle days: 7
end

app "#{cask_token}.app"
end
RUBY
end

it do
allow(Homebrew::Livecheck).to receive(:latest_version).and_return({
latest: Version.new("1.2.6"),
latest_throttled: Version.new("1.2.5"),
})
expect(run).not_to error_with(message)
end
Comment thread
bevanjkay marked this conversation as resolved.
end

context "when the Cask has a `livecheck` block referencing a Cask that uses `throttle`" do
let(:cask_token) { "livecheck-throttle-reference" }

Expand All @@ -648,6 +679,58 @@ def tmp_cask(name, text)
expect(run).not_to error_with(message)
end
end

context "when the Cask has a `livecheck` block referencing a Cask that uses `throttle days:`" do
let(:cask_token) { "livecheck-throttle-days-reference" }
let(:referenced_cask) do
tmp_cask "livecheck-throttle-days-source", <<~RUBY
cask "livecheck-throttle-days-source" do
version "1.2.5"
sha256 "8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b"

url "https://brew.sh/livecheck-throttle-days-source-1.2.5.dmg"
name "Throttle Days Source"
homepage "https://brew.sh/livecheck-throttle-days-source"

livecheck do
url :homepage
throttle days: 7
end

app "livecheck-throttle-days-source.app"
end
RUBY
end
let(:cask) do
tmp_cask cask_token.to_s, <<~RUBY
cask "#{cask_token}" do
version "1.2.5"
sha256 "8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b"

url "https://brew.sh/#{cask_token}-1.2.5.dmg"
name "Throttle Days Reference"
homepage "https://brew.sh/#{cask_token}"

livecheck do
cask "livecheck-throttle-days-source"
end

app "#{cask_token}.app"
end
RUBY
end

it do
allow(Homebrew::Livecheck).to receive_messages(
resolve_livecheck_reference: [referenced_cask, nil],
latest_version: {
latest: Version.new("1.2.6"),
latest_throttled: Version.new("1.2.5"),
},
)
expect(run).not_to error_with(message)
Comment thread
bevanjkay marked this conversation as resolved.
end
end
end

describe "when the Cask stanza requires uninstall" do
Expand Down
Loading