cask audit: check for latest with auto_updates

This commit is contained in:
commitay 2018-07-12 16:13:46 +10:00
parent 4ffc8b137b
commit ba929cd9e1
3 changed files with 47 additions and 0 deletions

View File

@ -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

View File

@ -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/ }

View File

@ -0,0 +1,11 @@
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