Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Handle nil autorequire results #22

Merged
merged 2 commits into from
Jan 24, 2022
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: 2 additions & 0 deletions lib/rspec-puppet/matchers/create_generic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ def relationship_refs(resource, type, visited = Set.new)
if resource.resource_type.respond_to?(func)
resource.resource_type.send(func) do |t, b|
Array(resource.to_ral.instance_eval(&b)).each do |dep|
next if dep.nil?

res = "#{t.to_s.capitalize}[#{dep}]"
if r = relationship_refs(res, type, visited)
results << res
Expand Down
17 changes: 0 additions & 17 deletions spec/classes/relationships__type_with_auto.rb

This file was deleted.

17 changes: 17 additions & 0 deletions spec/classes/relationships__type_with_auto_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require 'spec_helper'

describe 'relationships::type_with_auto', :if => Puppet::Util::Package.versioncmp(Puppet.version, '4.0.0') >= 0 do
it { is_expected.to compile.with_all_deps }
it do
is_expected.to contain_type_with_all_auto('test')
.that_comes_before('Notify[test/before]')
.that_notifies('Notify[test/notify]')
.that_requires('Notify[test/require]')
.that_subscribes_to('Notify[test/subscribe]')
end

it { is_expected.to contain_notify('test/before').that_requires('Type_with_all_auto[test]') }
it { is_expected.to contain_notify('test/notify').that_subscribes_to('Type_with_all_auto[test]') }
it { is_expected.to contain_notify('test/require').that_comes_before('Type_with_all_auto[test]') }
it { is_expected.to contain_notify('test/subscribe').that_notifies('Type_with_all_auto[test]') }
end
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Puppet::Type.newtype(:type_with_all_auto) do
ensurable
newparam(:name, :namevar => true)
autobefore(:file) { [File.join(self[:name], 'before')] }
autonotify(:file) { [File.join(self[:name], 'notify')] }
autorequire(:file) { [File.join(self[:name], 'require')] }
autosubscribe(:file) { [File.join(self[:name], 'subscribe')] }
autobefore(:notify) { ["#{self[:name]}/before", nil] }
autonotify(:notify) { ["#{self[:name]}/notify", nil] }
autorequire(:notify) { ["#{self[:name]}/require", nil] }
autosubscribe(:notify) { ["#{self[:name]}/subscribe", nil] }
end
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# This class is here to test type_with_all_auto which has alll auto* relations
class relationships::type_with_auto {
type_with_all_auto { '/tmp':
type_with_all_auto { 'test':
}

file { ['/tmp/before', '/tmp/notify', '/tmp/require', '/tmp/subscribe']:
ensure => file,
}
notify { ['test/before', 'test/notify', 'test/require', 'test/subscribe']: }
}