Skip to content
Snippets Groups Projects
Commit ba929cd9 authored by commitay's avatar commitay
Browse files

cask audit: check for `latest` with `auto_updates`

parent 4ffc8b13
No related branches found
No related tags found
No related merge requests found
......@@ -36,6 +36,7 @@ module Hbc
check_untrusted_pkg
check_hosting_with_appcast
check_latest_with_appcast
check_latest_with_auto_updates
check_stanza_requires_uninstall
self
rescue StandardError => e
......@@ -199,6 +200,13 @@ module Hbc
add_warning "Casks with an appcast should not use version :latest"
end
def check_latest_with_auto_updates
return unless cask.version.latest?
return unless cask.auto_updates
add_warning "Casks with `version :latest` should not use `auto_updates`"
end
def check_hosting_with_appcast
return if cask.appcast
......
......@@ -413,6 +413,34 @@ describe Hbc::Audit, :cask do
end
end
describe "latest with auto_updates checks" do
let(:warning_msg) { "Casks with `version :latest` should not use `auto_updates`" }
context "when the Cask is :latest and does not have auto_updates" do
let(:cask_token) { "version-latest" }
it { is_expected.not_to warn_with(warning_msg) }
end
context "when the Cask is versioned and does not have auto_updates" do
let(:cask_token) { "basic-cask" }
it { is_expected.not_to warn_with(warning_msg) }
end
context "when the Cask is versioned and has auto_updates" do
let(:cask_token) { "auto-updates" }
it { is_expected.not_to warn_with(warning_msg) }
end
context "when the Cask is :latest and has auto_updates" do
let(:cask_token) { "latest-with-auto-updates" }
it { is_expected.to warn_with(warning_msg) }
end
end
describe "preferred download URL formats" do
let(:warning_msg) { /URL format incorrect/ }
......
cask 'latest-with-auto-updates' do
version :latest
sha256 :no_check
url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
homepage 'http://example.com/latest-with-auto-updates'
auto_updates true
app 'Caffeine.app'
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment