diff options
| author | Can Eldem <celdem@gitlab.com> | 2020-01-09 11:26:40 +0000 |
|---|---|---|
| committer | Can Eldem <celdem@gitlab.com> | 2020-01-09 11:26:40 +0000 |
| commit | f16af48f9b7cf99e8d1cdb1e44dad9aad3a090b6 (patch) | |
| tree | 3944b2eade680f90739f2f3805dfec1a7bb1a360 /spec/unit/license/management/repository_spec.rb | |
| parent | d51e4d90b3e7dbfc5b0a9ec90f37baf84dc105d0 (diff) | |
| parent | d89872f850332736eb174f2b0ab28692fda6bf46 (diff) | |
Merge branch '35629-upgrade-python' into 'master'v2.3.0
Upgrade python from 3.5 to 3.8
See merge request gitlab-org/security-products/license-management!101
Diffstat (limited to 'spec/unit/license/management/repository_spec.rb')
| -rw-r--r-- | spec/unit/license/management/repository_spec.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/unit/license/management/repository_spec.rb b/spec/unit/license/management/repository_spec.rb new file mode 100644 index 0000000..6ebc09e --- /dev/null +++ b/spec/unit/license/management/repository_spec.rb @@ -0,0 +1,38 @@ +RSpec.describe License::Management::Repository do + describe "#item_for" do + let(:spdx_licenses) { JSON.parse(IO.read('spdx-licenses.json'))['licenses'] } + + context "when mapping a license that refers to opensource.org" do + it 'parses the SPDX id from the url' do + spdx_licenses.each do |license| + spdx_id = license['licenseId'] + url = "https://opensource.org/licenses/#{spdx_id}" + license = LicenseFinder::License.new(short_name: url, matcher: LicenseFinder::License::NoneMatcher.new, url: url) + expect(subject.item_for(license)['id']).to eql(spdx_id) + end + end + end + + context "when mapping a license that refers to nuget.org" do + it 'parses the SPDX id from the url' do + spdx_licenses.each do |license| + spdx_id = license['licenseId'] + url = "https://licenses.nuget.org/#{spdx_id}" + license = LicenseFinder::License.new(short_name: url, matcher: LicenseFinder::License::NoneMatcher.new, url: url) + expect(subject.item_for(license)['id']).to eql(spdx_id) + end + end + end + + [ + ['Apache License v2.0', 'Apache-2.0'], + ].each do |short_name, spdx_id| + context "when mapping a `#{short_name}` license" do + let(:license) { LicenseFinder::License.new(short_name: short_name, matcher: LicenseFinder::License::NoneMatcher.new, url: nil) } + let(:dependency) { double(name: 'x', summary: '', description: '', homepage: '', licenses: [license]) } + + it { expect(subject.item_for(license)['id']).to eql(spdx_id) } + end + end + end +end |
