cask audit: check for :latest with appcast

This commit is contained in:
commitay 2018-03-27 20:56:01 +10:00
parent 0851f96710
commit 2373ee6168
3 changed files with 38 additions and 0 deletions

View File

@ -35,6 +35,7 @@ module Hbc
check_single_uninstall_zap
check_untrusted_pkg
check_github_releases_appcast
check_latest_with_appcast
self
rescue StandardError => e
odebug "#{e.message}\n#{e.backtrace.join("\n")}"
@ -228,6 +229,13 @@ module Hbc
end
end
def check_latest_with_appcast
return unless cask.version.latest?
return unless cask.appcast
add_warning "Casks with an appcast should not use version :latest"
end
def check_github_releases_appcast
return if cask.appcast
return unless cask.url.to_s =~ %r{github.com/([^/]+)/([^/]+)/releases/download/(\S+)}

View File

@ -387,6 +387,25 @@ describe Hbc::Audit, :cask do
end
end
describe "latest with appcast checks" do
let(:error_msg) { "Casks with an appcast should not use version :latest" }
context "when the Cask is :latest and does not have an appcast" do
let(:cask_token) { "version-latest" }
it { should_not warn_with(error_msg) }
end
context "when the Cask is versioned and has an appcast" do
let(:cask_token) { "with-appcast" }
it { should_not warn_with(error_msg) }
end
context "when the Cask is :latest and has an appcast" do
let(:cask_token) { "latest-with-appcast" }
it { is_expected.to warn_with(error_msg) }
end
end
describe "preferred download URL formats" do
let(:warning_msg) { /URL format incorrect/ }

View File

@ -0,0 +1,11 @@
cask 'latest-with-appcast' do
version :latest
sha256 :no_check
url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
appcast 'http://example.com/appcast.xml',
checkpoint: '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
homepage 'http://example.com/with-appcast'
app 'Caffeine.app'
end