-
Notifications
You must be signed in to change notification settings - Fork 341
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Fix tests with updated license output [#163747415]
- Loading branch information
Vikram Yadav
committed
May 15, 2019
1 parent
1382b59
commit 3a3d854
Showing
15 changed files
with
201 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../../support/feature_helper' | ||
|
||
describe 'Trash Dependencies', :focus do | ||
let(:go_developer) { LicenseFinder::TestingDSL::User.new } | ||
|
||
context 'when the project does not contain trash.lock' do | ||
context 'when the project is not run with prepare' do | ||
specify 'fails to fetch the dependencies' do | ||
LicenseFinder::TestingDSL::TrashProject.create | ||
_output, status = go_developer.run_license_finder('gopath_trash') | ||
|
||
expect(status).to eq 1 | ||
expect(go_developer).to_not be_seeing_something_like %r{github.com/Masterminds/vcs} | ||
expect(go_developer).to_not be_seeing_something_like %r{gopkg.in/yaml.v2} | ||
end | ||
end | ||
|
||
context 'when the project is run with prepare' do | ||
specify 'shows dependencies in reports' do | ||
LicenseFinder::TestingDSL::TrashProject.create | ||
go_developer.run_license_finder('gopath_trash', '-p') | ||
|
||
expect(go_developer).to be_seeing_line 'github.com/Masterminds/vcs, v1.12.0, MIT' | ||
expect(go_developer).to be_seeing_line 'gopkg.in/yaml.v2, eb3733d160e74a9c7e442f435eb3bea458e1d19f, "Apache 2.0, MIT"' | ||
end | ||
end | ||
end | ||
|
||
context 'when the project contains trash.lock' do | ||
context 'when the project is not run with prepare' do | ||
specify 'shows dependencies in reports without license information' do | ||
LicenseFinder::TestingDSL::TrashProject.create | ||
go_developer.run_license_finder('gopath_trash') | ||
|
||
expect(go_developer).to_not be_seeing_line 'github.com/Masterminds/vcs, v1.12.0, unknown' | ||
expect(go_developer).to_not be_seeing_line 'gopkg.in/yaml.v2, eb3733d160e74a9c7e442f435eb3bea458e1d19f, unknown' | ||
end | ||
end | ||
|
||
context 'when the project is run with prepare' do | ||
specify 'shows dependencies in reports' do | ||
LicenseFinder::TestingDSL::PreparedTrashProject.create | ||
go_developer.run_license_finder('gopath_trash_prepared', '-p') | ||
|
||
expect(go_developer).to be_seeing_line 'github.com/Masterminds/vcs, v1.12.0, MIT' | ||
expect(go_developer).to be_seeing_line 'gopkg.in/yaml.v2, eb3733d160e74a9c7e442f435eb3bea458e1d19f, "Apache 2.0, MIT"' | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package main | ||
|
||
import ( | ||
"gopkg.in/yaml.v2" | ||
"github.com/Masterminds/vcs" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#package | ||
gopath_trash | ||
|
||
github.com/Masterminds/vcs v1.12.0 | ||
gopkg.in/yaml.v2 eb3733d160e74a9c7e442f435eb3bea458e1d19f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package main | ||
|
||
import ( | ||
"gopkg.in/yaml.v2" | ||
"github.com/Masterminds/vcs" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import: | ||
- package: github.com/Masterminds/vcs | ||
version: v1.12.0 | ||
- package: gopkg.in/yaml.v2 | ||
version: eb3733d160e74a9c7e442f435eb3bea458e1d19f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#package | ||
gopath_trash_prepared | ||
|
||
github.com/Masterminds/vcs v1.12.0 | ||
gopkg.in/yaml.v2 eb3733d160e74a9c7e442f435eb3bea458e1d19f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# frozen_string_literal: true | ||
|
||
module LicenseFinder | ||
class Trash < PackageManager | ||
class << self | ||
def package_management_command | ||
'trash' | ||
end | ||
|
||
def prepare_command | ||
'trash' | ||
end | ||
|
||
def takes_priority_over | ||
Go15VendorExperiment | ||
end | ||
end | ||
|
||
def possible_package_paths | ||
[project_path.join('vendor.conf')] | ||
end | ||
|
||
def current_packages | ||
dependencies_path = project_path.join('trash.lock') | ||
|
||
YAML.load_file(dependencies_path).fetch('import').map do |package_hash| | ||
import_path = package_hash.fetch('package') | ||
license_path = project_path.join('vendor', import_path) | ||
|
||
GoPackage.from_dependency({ | ||
'ImportPath' => import_path, | ||
'InstallPath' => license_path, | ||
'Rev' => package_hash.fetch('version') | ||
}, nil, true) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package: github.com/rancher/trash | ||
import: | ||
- package: some-package-name | ||
version: 123abc | ||
- package: another-package-name | ||
version: 456xyz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
require 'fakefs/spec_helpers' | ||
|
||
module LicenseFinder | ||
describe Trash do | ||
it_behaves_like 'a PackageManager' | ||
|
||
subject { Trash.new(project_path: Pathname('/app'), logger: double(:logger, active: nil, log: true)) } | ||
|
||
describe '.prepare_command' do | ||
it 'returns the correct prepare method' do | ||
expect(described_class.prepare_command).to eq('trash') | ||
end | ||
end | ||
|
||
describe '.package_management_command' do | ||
it 'returns the correct package management command' do | ||
expect(described_class.package_management_command).to eq('trash') | ||
end | ||
end | ||
|
||
describe '.takes_priority_over' do | ||
it 'returns the package manager it takes priority over' do | ||
expect(described_class.takes_priority_over).to eq(Go15VendorExperiment) | ||
end | ||
end | ||
|
||
describe '#current_packages' do | ||
let(:content) do | ||
FakeFS.without do | ||
fixture_from('trash.lock') | ||
end | ||
end | ||
|
||
it 'returns the packages described by trash.lock' do | ||
FakeFS.with_fresh do | ||
FileUtils.mkdir_p '/app' | ||
File.write(Pathname('/app/trash.lock').to_s, content) | ||
expect(subject.current_packages.length).to eq 2 | ||
|
||
expect(subject.current_packages.first.name).to eq 'some-package-name' | ||
expect(subject.current_packages.first.version).to eq '123abc' | ||
|
||
expect(subject.current_packages.last.name).to eq 'another-package-name' | ||
expect(subject.current_packages.last.version).to eq '456xyz' | ||
end | ||
end | ||
end | ||
end | ||
end |