Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

autorequire cli_jar from all PX::J::Type::Cli based types #486

Merged
merged 1 commit into from
Feb 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/puppet_x/jenkins/type/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def self.newtype(*args, &block)
config = PuppetX::Jenkins::Config.new(catalog)

autos = []
%w( ssh_private_key puppet_helper ).each do |param|
%w( ssh_private_key puppet_helper cli_jar ).each do |param|
value = config[param.to_sym]
autos << value unless value.nil?
end
Expand Down
67 changes: 67 additions & 0 deletions spec/unit/puppet_x/spec_jenkins_types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,73 @@
expect(req[1].source).to eq helper_resource
expect(req[1].target).to eq resource
end

it "should autorequire cli_jar file from catalog" do
helper_resource = Puppet::Type.type(:file).new(
:path => '/dne/catalog',
)
resource = described_class.new(
:name => 'test',
)
jenkins = Puppet::Type.type(:component).new(
:name => 'jenkins::cli::config',
:cli_jar => '/dne/catalog',
)

catalog = Puppet::Resource::Catalog.new
catalog.add_resource helper_resource
catalog.add_resource resource
catalog.add_resource jenkins
req = resource.autorequire

expect(req.size).to eq 1
expect(req[0].source).to eq helper_resource
expect(req[0].target).to eq resource
end

it "should autorequire cli_jar file from fact" do
helper_resource = Puppet::Type.type(:file).new(
:path => '/dne/fact',
)
resource = described_class.new(
:name => 'test',
)
Facter.add(:jenkins_cli_jar) { setcode { '/dne/fact' } }

catalog = Puppet::Resource::Catalog.new
catalog.add_resource helper_resource
catalog.add_resource resource
req = resource.autorequire

expect(req.size).to eq 1
expect(req[0].source).to eq helper_resource
expect(req[0].target).to eq resource
end

it "should autorequire cli_jar file from catalog instead of fact" do
helper_resource = Puppet::Type.type(:file).new(
:path => '/dne/catalog',
)
resource = described_class.new(
:name => 'test',
)
jenkins = Puppet::Type.type(:component).new(
:name => 'jenkins::cli::config',
:cli_jar => '/dne/catalog',
)
Facter.add(:jenkins_cli_jar) { setcode { '/dne/fact' } }

catalog = Puppet::Resource::Catalog.new
catalog.add_resource helper_resource
catalog.add_resource resource
catalog.add_resource jenkins
req = resource.autorequire

expect(req.size).to eq 1
expect(req[0].source).to eq helper_resource
expect(req[0].target).to eq resource
end

end # when autorequiring resources

shared_examples 'autorequires all jenkins_user resources' do
Expand Down