Skip to content

Commit b75ef40

Browse files
author
Kevin Paulisse
committed
Add more test conditions
1 parent 29767e9 commit b75ef40

1 file changed

Lines changed: 69 additions & 17 deletions

File tree

spec/octocatalog-diff/integration/preserve_environments_spec.rb

Lines changed: 69 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,83 @@
22

33
require_relative 'integration_helper'
44

5-
OctocatalogDiff::Spec.require_path('/catalog')
5+
OctocatalogDiff::Spec.require_path('/catalog-diff/cli/catalogs')
66

77
describe 'preserve environments integration' do
88
context 'without --preserve-environments set' do
9-
before(:all) do
10-
@result = OctocatalogDiff::Integration.integration(
11-
spec_fact_file: 'facts.yaml',
12-
spec_repo: 'preserve-environments',
13-
argv: [
14-
'-n', 'rspec-node.github.net',
15-
'--retry-failed-catalog', '0'
16-
]
17-
)
18-
end
9+
context 'without --environment set' do
10+
before(:all) do
11+
@result = OctocatalogDiff::Integration.integration(
12+
spec_fact_file: 'facts.yaml',
13+
spec_repo: 'preserve-environments',
14+
argv: [
15+
'-n', 'rspec-node.github.net',
16+
'--retry-failed-catalog', '0'
17+
]
18+
)
19+
end
20+
21+
it 'should exit with error status' do
22+
expect(@result.exitcode).to eq(-1), OctocatalogDiff::Integration.format_exception(@result)
23+
end
24+
25+
it 'should raise OctocatalogDiff::CatalogDiff::Cli::Catalogs::CatalogError' do
26+
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::CatalogDiff::Cli::Catalogs::CatalogError)
27+
end
1928

20-
it 'should exit with error status' do
21-
expect(@result.exitcode).to eq(-1), OctocatalogDiff::Integration.format_exception(@result)
29+
it 'should fail because ::bar could not be located' do
30+
expect(@result.exception.message).to match(/Could not find class ::bar for rspec-node.github.net/)
31+
end
2232
end
2333

24-
it 'should raise OctocatalogDiff::CatalogDiff::Cli::Catalogs::CatalogError' do
25-
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::CatalogDiff::Cli::Catalogs::CatalogError)
34+
context 'with --environment set' do
35+
before(:all) do
36+
@result = OctocatalogDiff::Integration.integration(
37+
spec_fact_file: 'facts.yaml',
38+
spec_repo_old: 'default',
39+
argv: [
40+
'-n', 'rspec-node.github.net',
41+
'--environment', 'asdfgh',
42+
'--to-catalog', OctocatalogDiff::Spec.fixture_path('catalogs/default-catalog-v4.json'),
43+
'--hiera-config', 'environments/production/config/hiera.yaml',
44+
'--hiera-path-strip', '/var/lib/puppet'
45+
]
46+
)
47+
end
48+
49+
it 'should exit without error' do
50+
expect(@result.exitcode).to eq(0), OctocatalogDiff::Integration.format_exception(@result)
51+
expect(@result.exception).to be_nil, OctocatalogDiff::Integration.format_exception(@result)
52+
end
53+
54+
it 'should log warning about --environment being useless in this context' do
55+
expect(@result.logs).to match(/WARN -- : --environment is ignored unless --preserve-environment is used/)
56+
end
2657
end
2758

28-
it 'should fail because ::bar could not be located' do
29-
expect(@result.exception.message).to match(/Could not find class ::bar for rspec-node.github.net/)
59+
context 'with --create-symlinks set' do
60+
before(:all) do
61+
@result = OctocatalogDiff::Integration.integration(
62+
spec_fact_file: 'facts.yaml',
63+
spec_repo_old: 'default',
64+
argv: [
65+
'-n', 'rspec-node.github.net',
66+
'--create-symlinks', 'asdfgh,asldfk',
67+
'--to-catalog', OctocatalogDiff::Spec.fixture_path('catalogs/default-catalog-v4.json'),
68+
'--hiera-config', 'environments/production/config/hiera.yaml',
69+
'--hiera-path-strip', '/var/lib/puppet'
70+
]
71+
)
72+
end
73+
74+
it 'should exit without error' do
75+
expect(@result.exitcode).to eq(0), OctocatalogDiff::Integration.format_exception(@result)
76+
expect(@result.exception).to be_nil, OctocatalogDiff::Integration.format_exception(@result)
77+
end
78+
79+
it 'should log warning about --create-symlinks being useless in this context' do
80+
expect(@result.logs).to match(/WARN -- : --create-symlinks is ignored unless --preserve-environment is used/)
81+
end
3082
end
3183
end
3284

0 commit comments

Comments
 (0)