Skip to content

Commit 6ef84d9

Browse files
author
Kevin Paulisse
committed
Update tests and fixtures with more complete errors and to test custom defined type
1 parent 554f573 commit 6ef84d9

5 files changed

Lines changed: 39 additions & 5 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
define test::foo::bar {
2+
exec { "test::foo::bar ${name}":
3+
command => '/bin/true',
4+
}
5+
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
class test::notify_callers {
22
exec { 'notify caller':
3-
command => '/bin/true',
4-
notify => Exec['notify target'],
3+
notify => Test::Foo::Bar['notify target'],
54
}
65
}
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
class test::notify_targets {
2-
exec { 'notify target':
3-
command => '/bin/true',
4-
}
2+
test::foo::bar { 'notify target': }
53
}

spec/octocatalog-diff/fixtures/repos/reference-validation/modules/test/manifests/require_callers.pp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,17 @@
33
command => '/bin/true',
44
require => Exec['require target'],
55
}
6+
7+
exec { 'require caller 2':
8+
command => '/bin/true',
9+
require => Exec['require caller'],
10+
}
11+
12+
exec { ['require caller 3', 'require caller 4']:
13+
command => '/bin/true',
14+
require => [
15+
Exec['require caller'],
16+
Exec['require target'],
17+
]
18+
}
619
}

spec/octocatalog-diff/integration/reference_validation_spec.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ def self.catalog_contains_resource(result, type, title)
9898
it 'should raise ReferenceValidationError' do
9999
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Catalog::ReferenceValidationError)
100100
end
101+
102+
it 'should have formatted error messages' do
103+
msg = @result.exception.message
104+
expect(msg).to eq('Catalog has broken reference: exec[before caller] -> before[Exec[before target]]')
105+
end
101106
end
102107

103108
context 'with broken notify' do
@@ -112,6 +117,11 @@ def self.catalog_contains_resource(result, type, title)
112117
it 'should raise ReferenceValidationError' do
113118
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Catalog::ReferenceValidationError)
114119
end
120+
121+
it 'should have formatted error messages' do
122+
msg = @result.exception.message
123+
expect(msg).to match(/exec\[notify caller\] -> notify\[Test::Foo::Bar\[notify target\]\]/)
124+
end
115125
end
116126

117127
context 'with broken require' do
@@ -126,6 +136,15 @@ def self.catalog_contains_resource(result, type, title)
126136
it 'should raise ReferenceValidationError' do
127137
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Catalog::ReferenceValidationError)
128138
end
139+
140+
it 'should have formatted error messages' do
141+
msg = @result.exception.message
142+
expect(msg).to match(/exec\[require caller\] -> require\[Exec\[require target\]\]/)
143+
expect(msg).to match(/exec\[require caller 3\] -> require\[Exec\[require target\]\]/)
144+
expect(msg).to match(/exec\[require caller 4\] -> require\[Exec\[require target\]\]/)
145+
expect(msg).not_to match(/exec\[require caller 2\]/)
146+
expect(msg).not_to match(/-> require\[Exec\[require caller\]\]/)
147+
end
129148
end
130149

131150
context 'with broken subscribe but subscribe not checked' do

0 commit comments

Comments
 (0)