Merge pull request #2240 from linc01n/audit
Check no_checksum if version is latest in audit
This commit is contained in:
commit
b850d78427
|
@ -13,6 +13,7 @@ class Cask::Audit
|
|||
def run!(download = false)
|
||||
_check_required_fields
|
||||
_check_checksums
|
||||
_check_no_checksums_if_latest
|
||||
_check_sourceforge_download_url_format
|
||||
_check_download(download) if download
|
||||
end
|
||||
|
@ -33,6 +34,10 @@ class Cask::Audit
|
|||
add_error "could not find checksum or no_checksum" unless cask.sums.is_a?(Array) && cask.sums.length > 0
|
||||
end
|
||||
|
||||
def _check_no_checksums_if_latest
|
||||
add_error "you should use no_checksum when version is latest" if cask.version == "latest" && cask.sums.is_a?(Array)
|
||||
end
|
||||
|
||||
def _check_download(download)
|
||||
download.perform
|
||||
rescue => e
|
||||
|
|
|
@ -33,6 +33,10 @@ class CaskSourceForgeOtherCorrectURLFormat < Cask
|
|||
url 'http://sourceforge.net/projects/something/files/latest/download'
|
||||
end
|
||||
|
||||
class CaskVersionLatestWithChecksum < Cask
|
||||
version 'latest'
|
||||
sha1 '123456'
|
||||
end
|
||||
|
||||
describe Cask::Audit do
|
||||
describe "result" do
|
||||
|
@ -74,6 +78,12 @@ describe Cask::Audit do
|
|||
audit.run!
|
||||
audit.errors.must_include 'homepage is required'
|
||||
end
|
||||
|
||||
it "adds an error if version is latest and using sha1" do
|
||||
audit = Cask::Audit.new(CaskVersionLatestWithChecksum.new)
|
||||
audit.run!
|
||||
audit.errors.must_include 'you should use no_checksum when version is latest'
|
||||
end
|
||||
end
|
||||
|
||||
describe "preferred download URL formats" do
|
||||
|
|
Loading…
Reference in New Issue