Skip to content

Commit b5e81c2

Browse files
author
Kevin Paulisse
committed
Finish up integration test and fixtures
1 parent a8e6406 commit b5e81c2

5 files changed

Lines changed: 78 additions & 37 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
modulepath = modules:site:$basemodulepath
1+
modulepath = ../../modules:../../site:./modules
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node default {
2+
include foo
3+
include bar
4+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
modulepath = modules:site:$basemodulepath
1+
modulepath = ../../modules:../../site:./modules
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node default {
2+
include foo
3+
include bar
4+
}

spec/octocatalog-diff/integration/preserve_environments_spec.rb

Lines changed: 68 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,10 @@
9696
)
9797
end
9898

99-
it 'should exit with error status' do
99+
it 'should exit with error status due modules in production environment not being found' do
100100
expect(@result.exitcode).to eq(-1), OctocatalogDiff::Integration.format_exception(@result)
101-
end
102-
103-
it 'should raise OctocatalogDiff::CatalogDiff::Cli::Catalogs::CatalogError' do
104101
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::CatalogDiff::Cli::Catalogs::CatalogError)
105-
end
106-
107-
it 'should fail because ::bar could not be located' do
108-
expect(@result.exception.message).to match(/Could not find class ::bar for rspec-node.github.net/)
102+
expect(@result.exception.message).to match(/Errno::ENOENT: No such file or directory - Environment directory/)
109103
end
110104
end
111105

@@ -120,19 +114,20 @@
120114
'--preserve-environments',
121115
'--from-environment', 'one',
122116
'--to-environment', 'fluffy',
123-
'--create-symlinks', 'modules,sitetest'
117+
'--create-symlinks', 'modules,site'
124118
]
125119
)
126120
end
127121

128122
it 'should error on missing environment' do
129-
expect(@result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(@result)
130-
expect(@result.exception).to be_nil, OctocatalogDiff::Integration.format_exception(@result)
123+
expect(@result.exitcode).to eq(-1), OctocatalogDiff::Integration.format_exception(@result)
124+
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::CatalogDiff::Cli::Catalogs::CatalogError)
125+
expect(@result.exception.message).to match(%r{Environment directory .+/environments/fluffy does not exist})
131126
end
132127
end
133128

134129
context 'and --create-symlinks set' do
135-
context 'to modules,sitetest' do
130+
context 'to modules,site' do
136131
before(:all) do
137132
@result = OctocatalogDiff::Integration.integration(
138133
spec_fact_file: 'facts.yaml',
@@ -142,7 +137,7 @@
142137
'--preserve-environments',
143138
'--from-environment', 'one',
144139
'--to-environment', 'two',
145-
'--create-symlinks', 'modules,sitetest'
140+
'--create-symlinks', 'modules,site'
146141
]
147142
)
148143
end
@@ -151,6 +146,38 @@
151146
expect(@result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(@result)
152147
expect(@result.exception).to be_nil, OctocatalogDiff::Integration.format_exception(@result)
153148
end
149+
150+
it 'should display proper diffs' do
151+
diffs = @result.diffs
152+
153+
expect(
154+
OctocatalogDiff::Spec.array_contains_partial_array?(
155+
diffs,
156+
['~', "File\f/tmp/bar\fparameters\fcontent", 'one', 'two']
157+
)
158+
).to eq(true)
159+
160+
expect(
161+
OctocatalogDiff::Spec.array_contains_partial_array?(
162+
diffs,
163+
['~', "File\f/tmp/bar\fparameters\fowner", 'one', 'two']
164+
)
165+
).to eq(true)
166+
167+
expect(
168+
OctocatalogDiff::Spec.array_contains_partial_array?(
169+
diffs,
170+
['~', "File\f/tmp/foo\fparameters\fcontent", 'one', 'two']
171+
)
172+
).to eq(true)
173+
174+
expect(
175+
OctocatalogDiff::Spec.array_contains_partial_array?(
176+
diffs,
177+
['~', "File\f/tmp/sitetest\fparameters\fcontent", 'one', 'two']
178+
)
179+
).to eq(true)
180+
end
154181
end
155182

156183
context 'to modules' do
@@ -159,7 +186,7 @@
159186
spec_fact_file: 'facts.yaml',
160187
spec_repo: 'preserve-environments',
161188
argv: [
162-
'-n', 'rspec-node.github.net',
189+
'-n', 'rspec-node.github.net', '--no-parallel',
163190
'--retry-failed-catalog', '0',
164191
'--preserve-environments',
165192
'--from-environment', 'one',
@@ -169,31 +196,33 @@
169196
)
170197
end
171198

172-
it 'should error on missing sitetest' do
173-
expect(@result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(@result)
174-
expect(@result.exception).to be_nil, OctocatalogDiff::Integration.format_exception(@result)
199+
it 'should error on missing site directory' do
200+
expect(@result.exitcode).to eq(-1), OctocatalogDiff::Integration.format_exception(@result)
201+
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::CatalogDiff::Cli::Catalogs::CatalogError)
202+
expect(@result.exception.message).to match(/Could not find class (::)?sitetest/)
175203
end
176204
end
177205

178-
context 'to sitetest' do
206+
context 'to site' do
179207
before(:all) do
180208
@result = OctocatalogDiff::Integration.integration(
181209
spec_fact_file: 'facts.yaml',
182210
spec_repo: 'preserve-environments',
183211
argv: [
184-
'-n', 'rspec-node.github.net',
212+
'-n', 'rspec-node.github.net', '--no-parallel',
185213
'--retry-failed-catalog', '0',
186214
'--preserve-environments',
187215
'--from-environment', 'one',
188216
'--to-environment', 'two',
189-
'--create-symlinks', 'sitetest'
217+
'--create-symlinks', 'site'
190218
]
191219
)
192220
end
193221

194222
it 'should error on missing module' do
195-
expect(@result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(@result)
196-
expect(@result.exception).to be_nil, OctocatalogDiff::Integration.format_exception(@result)
223+
expect(@result.exitcode).to eq(-1), OctocatalogDiff::Integration.format_exception(@result)
224+
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::CatalogDiff::Cli::Catalogs::CatalogError)
225+
expect(@result.exception.message).to match(/Could not find class (::)?foo/)
197226
end
198227
end
199228

@@ -203,7 +232,7 @@
203232
spec_fact_file: 'facts.yaml',
204233
spec_repo: 'preserve-environments',
205234
argv: [
206-
'-n', 'rspec-node.github.net',
235+
'-n', 'rspec-node.github.net', '--no-parallel',
207236
'--retry-failed-catalog', '0',
208237
'--preserve-environments',
209238
'--from-environment', 'one',
@@ -213,9 +242,11 @@
213242
)
214243
end
215244

216-
it 'should error on missing symlink' do
217-
expect(@result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(@result)
218-
expect(@result.exception).to be_nil, OctocatalogDiff::Integration.format_exception(@result)
245+
it 'should raise exception due to missing symlink request' do
246+
expect(@result.exitcode).to eq(-1), OctocatalogDiff::Integration.format_exception(@result)
247+
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::CatalogDiff::Cli::Catalogs::CatalogError)
248+
expect(@result.exception.message).to match(%r{Catalog for 'from' \(origin/master\) failed.+ Errno::ENOENT})
249+
expect(@result.exception.message).to match(%r{Specified directory .+/preserve-environments/fluffy doesn't exist})
219250
end
220251
end
221252
end
@@ -231,8 +262,8 @@
231262
'--preserve-environments',
232263
'--from-environment', 'one',
233264
'--to-environment', 'two',
234-
'--to-create-symlinks', 'modules,sitetest',
235-
'--from-create-symlinks', 'sitetest,modules'
265+
'--to-create-symlinks', 'modules,site',
266+
'--from-create-symlinks', 'site,modules'
236267
]
237268
)
238269
end
@@ -255,14 +286,15 @@
255286
'--from-environment', 'one',
256287
'--to-environment', 'two',
257288
'--to-create-symlinks', 'modules',
258-
'--from-create-symlinks', 'modules,sitetest'
289+
'--from-create-symlinks', 'modules,site'
259290
]
260291
)
261292
end
262293

263-
it 'should error to-catalog missing sitetest' do
264-
expect(@result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(@result)
265-
expect(@result.exception).to be_nil, OctocatalogDiff::Integration.format_exception(@result)
294+
it 'should error on missing site directory' do
295+
expect(@result.exitcode).to eq(-1), OctocatalogDiff::Integration.format_exception(@result)
296+
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::CatalogDiff::Cli::Catalogs::CatalogError)
297+
expect(@result.exception.message).to match(%r{Could not find class (::)?sitetest.+ at .+/environments/two/})
266298
end
267299
end
268300
end
@@ -282,9 +314,10 @@
282314
)
283315
end
284316

285-
it 'should error on missing module' do
286-
expect(@result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(@result)
287-
expect(@result.exception).to be_nil, OctocatalogDiff::Integration.format_exception(@result)
317+
it 'should error on missing site directory' do
318+
expect(@result.exitcode).to eq(-1), OctocatalogDiff::Integration.format_exception(@result)
319+
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::CatalogDiff::Cli::Catalogs::CatalogError)
320+
expect(@result.exception.message).to match(/Could not find class (::)?sitetest/)
288321
end
289322
end
290323
end

0 commit comments

Comments
 (0)