Skip to content

Commit 9cbd0ab

Browse files
author
Kevin Paulisse
committed
Add additional module directory
1 parent f8d8890 commit 9cbd0ab

6 files changed

Lines changed: 184 additions & 2 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
modulepath = ./modules:$basemodulepath
1+
modulepath = modules:site:$basemodulepath

spec/octocatalog-diff/fixtures/repos/preserve-environments/environments/one/modules/bar/manifests/init.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
class bar {
2+
include sitetest
3+
24
file { '/tmp/bar':
35
owner => 'one',
46
content => $::environment,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
modulepath = ./modules:$basemodulepath
1+
modulepath = modules:site:$basemodulepath

spec/octocatalog-diff/fixtures/repos/preserve-environments/environments/two/modules/bar/manifests/init.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
class bar {
2+
include sitetest
3+
24
file { '/tmp/bar':
35
owner => 'two',
46
content => $::environment,
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class sitetest {
2+
file { '/tmp/sitetest':
3+
owner => 'sitetest',
4+
content => $::environment,
5+
}
6+
}

spec/octocatalog-diff/integration/preserve_environments_spec.rb

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,177 @@
3030
end
3131

3232
context 'with --preserve-environments set' do
33+
context 'and --environment set to non-existent value' do
34+
before(:all) do
35+
@result = OctocatalogDiff::Integration.integration(
36+
spec_fact_file: 'facts.yaml',
37+
spec_repo: 'preserve-environments',
38+
argv: [
39+
'-n', 'rspec-node.github.net',
40+
'--preserve-environments',
41+
'--from-environment', 'one',
42+
'--to-environment', 'fluffy',
43+
'--create-symlinks', 'modules,sitetest'
44+
]
45+
)
46+
end
47+
48+
it 'should error on missing environment' do
49+
expect(@result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(@result)
50+
expect(@result.exception).to be_nil, OctocatalogDiff::Integration.format_exception(@result)
51+
end
52+
end
53+
54+
context 'and --create-symlinks set' do
55+
context 'to modules,sitetest' do
56+
before(:all) do
57+
@result = OctocatalogDiff::Integration.integration(
58+
spec_fact_file: 'facts.yaml',
59+
spec_repo: 'preserve-environments',
60+
argv: [
61+
'-n', 'rspec-node.github.net',
62+
'--preserve-environments',
63+
'--from-environment', 'one',
64+
'--to-environment', 'two',
65+
'--create-symlinks', 'modules,sitetest'
66+
]
67+
)
68+
end
69+
70+
it 'should exit without error' do
71+
expect(@result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(@result)
72+
expect(@result.exception).to be_nil, OctocatalogDiff::Integration.format_exception(@result)
73+
end
74+
end
75+
76+
context 'to modules' do
77+
before(:all) do
78+
@result = OctocatalogDiff::Integration.integration(
79+
spec_fact_file: 'facts.yaml',
80+
spec_repo: 'preserve-environments',
81+
argv: [
82+
'-n', 'rspec-node.github.net',
83+
'--preserve-environments',
84+
'--from-environment', 'one',
85+
'--to-environment', 'two',
86+
'--create-symlinks', 'modules'
87+
]
88+
)
89+
end
90+
91+
it 'should error on missing sitetest' do
92+
expect(@result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(@result)
93+
expect(@result.exception).to be_nil, OctocatalogDiff::Integration.format_exception(@result)
94+
end
95+
end
96+
97+
context 'to sitetest' do
98+
before(:all) do
99+
@result = OctocatalogDiff::Integration.integration(
100+
spec_fact_file: 'facts.yaml',
101+
spec_repo: 'preserve-environments',
102+
argv: [
103+
'-n', 'rspec-node.github.net',
104+
'--preserve-environments',
105+
'--from-environment', 'one',
106+
'--to-environment', 'two',
107+
'--create-symlinks', 'sitetest'
108+
]
109+
)
110+
end
111+
112+
it 'should error on missing module' do
113+
expect(@result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(@result)
114+
expect(@result.exception).to be_nil, OctocatalogDiff::Integration.format_exception(@result)
115+
end
116+
end
117+
118+
context 'to missing value' do
119+
before(:all) do
120+
@result = OctocatalogDiff::Integration.integration(
121+
spec_fact_file: 'facts.yaml',
122+
spec_repo: 'preserve-environments',
123+
argv: [
124+
'-n', 'rspec-node.github.net',
125+
'--preserve-environments',
126+
'--from-environment', 'one',
127+
'--to-environment', 'two',
128+
'--create-symlinks', 'modules,fluffy'
129+
]
130+
)
131+
end
132+
133+
it 'should error on missing symlink' do
134+
expect(@result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(@result)
135+
expect(@result.exception).to be_nil, OctocatalogDiff::Integration.format_exception(@result)
136+
end
137+
end
138+
end
139+
140+
context 'and --to-create-symlinks, --from-create-symlinks set' do
141+
context 'to modules,sitetest' do
142+
before(:all) do
143+
@result = OctocatalogDiff::Integration.integration(
144+
spec_fact_file: 'facts.yaml',
145+
spec_repo: 'preserve-environments',
146+
argv: [
147+
'-n', 'rspec-node.github.net',
148+
'--preserve-environments',
149+
'--from-environment', 'one',
150+
'--to-environment', 'two',
151+
'--to-create-symlinks', 'modules,sitetest',
152+
'--from-create-symlinks', 'sitetest,modules'
153+
]
154+
)
155+
end
156+
157+
it 'should succeed' do
158+
expect(@result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(@result)
159+
expect(@result.exception).to be_nil, OctocatalogDiff::Integration.format_exception(@result)
160+
end
161+
end
162+
163+
context 'to different values' do
164+
before(:all) do
165+
@result = OctocatalogDiff::Integration.integration(
166+
spec_fact_file: 'facts.yaml',
167+
spec_repo: 'preserve-environments',
168+
argv: [
169+
'-n', 'rspec-node.github.net',
170+
'--preserve-environments',
171+
'--from-environment', 'one',
172+
'--to-environment', 'two',
173+
'--to-create-symlinks', 'modules',
174+
'--from-create-symlinks', 'modules,sitetest'
175+
]
176+
)
177+
end
178+
179+
it 'should error to-catalog missing sitetest' do
180+
expect(@result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(@result)
181+
expect(@result.exception).to be_nil, OctocatalogDiff::Integration.format_exception(@result)
182+
end
183+
end
184+
end
185+
186+
context 'and --create-symlinks unset' do
187+
before(:all) do
188+
@result = OctocatalogDiff::Integration.integration(
189+
spec_fact_file: 'facts.yaml',
190+
spec_repo: 'preserve-environments',
191+
argv: [
192+
'-n', 'rspec-node.github.net',
193+
'--preserve-environments',
194+
'--from-environment', 'one',
195+
'--to-environment', 'two'
196+
]
197+
)
198+
end
199+
200+
it 'should error on missing module' do
201+
expect(@result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(@result)
202+
expect(@result.exception).to be_nil, OctocatalogDiff::Integration.format_exception(@result)
203+
end
204+
end
33205
end
34206
end

0 commit comments

Comments
 (0)