-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(PDK-508) implement autorequire and friends
The spec/classes/autorequire_cycle_spec.rb test shows that the autorelations implementation of the Resource API does build relations. Since rspec-puppet doesn't provide matching on compile errors, this builds a test case that compiles when make_cycle is false, thereby proving that there is no error in the manifest, but fails with a dependency cycle error when make_cycle is set to true.
- Loading branch information
Showing
6 changed files
with
112 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,14 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe 'test_module::autorequire_cycle' do | ||
it { is_expected.to compile } | ||
context 'with make_cycle => false' do | ||
let(:params) { { make_cycle: false } } | ||
|
||
it { is_expected.to compile } | ||
end | ||
context 'with make_cycle => true' do | ||
let(:params) { { make_cycle: true } } | ||
|
||
it { is_expected.not_to compile } | ||
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
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 |
---|---|---|
@@ -1,10 +1,23 @@ | ||
# test_module::autorequire_cycle | ||
# | ||
# A description of what this class does | ||
# This class is used to test autorequires. | ||
# With make_cycle set to false, this should compile without errors or cycles. When make_cycle is set to true, autorequires will be used to | ||
# construct a dependency cycle. This makes it possible to test exactly the function of the autorequires implementation. | ||
# | ||
# @summary A short summary of the purpose of this class | ||
# @summary This class is used to test autorequires. | ||
# | ||
# @example | ||
# include test_module::autorequire_cycle | ||
class test_module::autorequire_cycle { | ||
class test_module::autorequire_cycle ( | ||
Boolean $make_cycle | ||
) { | ||
test_autorequire { "a": | ||
target => "b", | ||
} | ||
test_autorequire { "b": | ||
target => "c", | ||
} | ||
test_autorequire { "c": | ||
target => $make_cycle ? { true => "a", false => undef }, | ||
} | ||
} |
15 changes: 9 additions & 6 deletions
15
spec/fixtures/test_module/spec/classes/autorequire_cycle_spec.rb
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 |
---|---|---|
@@ -1,11 +1,14 @@ | ||
require 'spec_helper' | ||
|
||
describe 'test_module::autorequire_cycle' do | ||
on_supported_os.each do |os, os_facts| | ||
context "on #{os}" do | ||
let(:facts) { os_facts } | ||
RSpec.describe 'test_module::autorequire_cycle' do | ||
context 'with make_cycle => false' do | ||
let(:params) { { make_cycle: false } } | ||
|
||
it { is_expected.to compile } | ||
end | ||
it { is_expected.to compile } | ||
end | ||
context 'with make_cycle => true' do | ||
let(:params) { { make_cycle: true } } | ||
|
||
it { is_expected.not_to compile } | ||
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