test: add spdx spec
This commit is contained in:
parent
753b8621df
commit
6ecef73131
32
Library/Homebrew/test/utils/spdx_spec.rb
Normal file
32
Library/Homebrew/test/utils/spdx_spec.rb
Normal file
@ -0,0 +1,32 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "utils/spdx"
|
||||
|
||||
describe SPDX do
|
||||
describe ".spdx_data" do
|
||||
it "has the license list version" do
|
||||
expect(described_class.spdx_data["licenseListVersion"]).not_to eq(nil)
|
||||
end
|
||||
|
||||
it "has the release date" do
|
||||
expect(described_class.spdx_data["releaseDate"]).not_to eq(nil)
|
||||
end
|
||||
|
||||
it "has licenses" do
|
||||
expect(described_class.spdx_data["licenses"].length).not_to eq(0)
|
||||
end
|
||||
end
|
||||
|
||||
describe ".download_latest_license_data!", :needs_network do
|
||||
let(:tmp_json_path) { Pathname.new("#{TEST_TMPDIR}/spdx.json") }
|
||||
|
||||
after do
|
||||
FileUtils.rm tmp_json_path
|
||||
end
|
||||
|
||||
it "downloads latest license data" do
|
||||
described_class.download_latest_license_data! to: tmp_json_path
|
||||
expect(tmp_json_path).to exist
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -12,9 +12,9 @@ module SPDX
|
||||
@spdx_data ||= JSON.parse(JSON_PATH.read)
|
||||
end
|
||||
|
||||
def download_latest_license_data!
|
||||
def download_latest_license_data!(to: JSON_PATH)
|
||||
latest_tag = GitHub.open_api(API_URL)["tag_name"]
|
||||
data_url = "https://raw.githubusercontent.com/spdx/license-list-data/#{latest_tag}/json/licenses.json"
|
||||
curl_download(data_url, to: JSON_PATH, partial: false)
|
||||
curl_download(data_url, to: to, partial: false)
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user