Skip to content

Commit 7de36fc

Browse files
author
Kevin Paulisse
committed
Update tests for error classes
1 parent 6aa1920 commit 7de36fc

8 files changed

Lines changed: 38 additions & 26 deletions

File tree

bin/octocatalog-diff

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ logger = Logger.new(STDERR)
2424
logger.level = Logger::DEBUG if config_test
2525

2626
options = OctocatalogDiff::API::V1.config(logger: logger, test: config_test)
27-
exit(0) if config_test
27+
if config_test
28+
logger.info 'Exiting now because --config-test was specified'
29+
exit(0)
30+
end
2831

2932
argv = ARGV.dup
3033
exit_code = OctocatalogDiff::Cli.cli(argv, Logger.new(STDERR), options)

doc/dev/api/v1/catalog.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,17 @@
66

77
```
88
catalog_obj = OctocatalogDiff::API::V1.catalog(
9-
filename: "String",
10-
logger: Logger,
11-
test: <true|false>
9+
1210
)
1311
```
12+
13+
## Options
14+
15+
16+
**NOTE**: Additional options as described in the [options reference](/doc/optionsref.md) may also have an effect on catalog generation.
17+
18+
## Return value
19+
20+
The return value is an [`OctocatalogDiff::Catalog`](/doc/dev/api/v1/octocatalogdiff-catalog.md) object.
21+
22+
## Exceptions

spec/octocatalog-diff/integration/api_catalog_compile_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
}
5656
expect do
5757
described_class.catalog(options)
58-
end.to raise_error(OctocatalogDiff::Util::Catalogs::CatalogError)
58+
end.to raise_error(OctocatalogDiff::Errors::CatalogError)
5959
end
6060
end
6161

spec/octocatalog-diff/integration/convert_file_resources_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
]
119119
)
120120
expect(result[:exitcode]).to eq(-1)
121-
expect(result[:exception]).to be_a_kind_of(OctocatalogDiff::Util::Catalogs::CatalogError)
121+
expect(result[:exception]).to be_a_kind_of(OctocatalogDiff::Errors::CatalogError)
122122
expect(result[:exception].message).to match(/failed to compile with Errno::ENOENT/)
123123
expect(result[:exception].message).to match(%r{Unable to resolve 'puppet:///modules/test/foo-new'})
124124
end

spec/octocatalog-diff/integration/pe_enc_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def self.respond(code, message, content_type = nil, body = '')
129129
}
130130
result = OctocatalogDiff::Integration.integration(opts)
131131
expect(result[:exitcode]).to eq(-1)
132-
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Util::Catalogs::CatalogError')
132+
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Errors::CatalogError')
133133
expect(result[:exception].message).to match(/OpenSSL::SSL::SSLError/)
134134
end
135135

@@ -194,7 +194,7 @@ def self.respond(code, message, content_type = nil, body = '')
194194
}
195195
result = OctocatalogDiff::Integration.integration(opts)
196196
expect(result[:exitcode]).to eq(-1)
197-
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Util::Catalogs::CatalogError')
197+
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Errors::CatalogError')
198198
expect(result[:exception].message).to match(/Failed ENC: Response from https:.+rspec-node.xyz.github.net was 403/)
199199
end
200200

@@ -212,7 +212,7 @@ def self.respond(code, message, content_type = nil, body = '')
212212
}
213213
result = OctocatalogDiff::Integration.integration(opts)
214214
expect(result[:exitcode]).to eq(-1)
215-
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Util::Catalogs::CatalogError')
215+
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Errors::CatalogError')
216216
expect(result[:exception].message).to match(/Failed ENC: Response from https:.+rspec-node.xyz.github.net was 403/)
217217
end
218218

spec/octocatalog-diff/integration/preserve_environments_spec.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
expect(@result.exitcode).to eq(-1), OctocatalogDiff::Integration.format_exception(@result)
2323
end
2424

25-
it 'should raise OctocatalogDiff::Util::Catalogs::CatalogError' do
26-
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Util::Catalogs::CatalogError)
25+
it 'should raise OctocatalogDiff::Errors::CatalogError' do
26+
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Errors::CatalogError)
2727
end
2828

2929
it 'should fail because ::bar could not be located' do
@@ -98,7 +98,7 @@
9898

9999
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-
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Util::Catalogs::CatalogError)
101+
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Errors::CatalogError)
102102
expect(@result.exception.message).to match(/Errno::ENOENT: No such file or directory - Environment directory/)
103103
end
104104
end
@@ -121,7 +121,7 @@
121121

122122
it 'should error on missing environment' do
123123
expect(@result.exitcode).to eq(-1), OctocatalogDiff::Integration.format_exception(@result)
124-
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Util::Catalogs::CatalogError)
124+
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Errors::CatalogError)
125125
expect(@result.exception.message).to match(%r{Environment directory .+/environments/fluffy does not exist})
126126
end
127127
end
@@ -208,7 +208,7 @@
208208

209209
it 'should error on missing site directory' do
210210
expect(@result.exitcode).to eq(-1), OctocatalogDiff::Integration.format_exception(@result)
211-
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Util::Catalogs::CatalogError)
211+
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Errors::CatalogError)
212212
expect(@result.exception.message).to match(/Could not find class (::)?sitetest/)
213213
end
214214
end
@@ -231,7 +231,7 @@
231231

232232
it 'should error on missing module' do
233233
expect(@result.exitcode).to eq(-1), OctocatalogDiff::Integration.format_exception(@result)
234-
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Util::Catalogs::CatalogError)
234+
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Errors::CatalogError)
235235
expect(@result.exception.message).to match(/Could not find class (::)?foo/)
236236
end
237237
end
@@ -254,7 +254,7 @@
254254

255255
it 'should raise exception due to missing symlink request' do
256256
expect(@result.exitcode).to eq(-1), OctocatalogDiff::Integration.format_exception(@result)
257-
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Util::Catalogs::CatalogError)
257+
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Errors::CatalogError)
258258
expect(@result.exception.message).to match(%r{Catalog for 'from' \(origin/master\) failed.+ Errno::ENOENT})
259259
expect(@result.exception.message).to match(%r{Specified directory .+/preserve-environments/fluffy doesn't exist})
260260
end
@@ -303,7 +303,7 @@
303303

304304
it 'should error on missing site directory' do
305305
expect(@result.exitcode).to eq(-1), OctocatalogDiff::Integration.format_exception(@result)
306-
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Util::Catalogs::CatalogError)
306+
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Errors::CatalogError)
307307
expect(@result.exception.message).to match(/Could not find class (::)?sitetest/)
308308
end
309309
end
@@ -326,7 +326,7 @@
326326

327327
it 'should error on missing site directory' do
328328
expect(@result.exitcode).to eq(-1), OctocatalogDiff::Integration.format_exception(@result)
329-
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Util::Catalogs::CatalogError)
329+
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Errors::CatalogError)
330330
expect(@result.exception.message).to match(/Could not find class (::)?sitetest/)
331331
end
332332
end

spec/octocatalog-diff/integration/puppetdb_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
opts = { argv: ['-n', 'not-found-node.github.net'], spec_repo: 'tiny-repo' }
2323
result = OctocatalogDiff::Integration.integration_with_puppetdb(s_opts, opts)
2424
expect(result[:exitcode]).to eq(-1), OctocatalogDiff::Integration.format_exception(result)
25-
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Util::Catalogs::CatalogError')
25+
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Errors::CatalogError')
2626
expect(result[:exception].message).to match(/FactRetrievalError: Node not-found-node.github.net not found in PuppetDB/)
2727
end
2828
end
@@ -53,7 +53,7 @@
5353
opts = { argv: args, spec_repo: 'tiny-repo' }
5454
result = OctocatalogDiff::Integration.integration_with_puppetdb(s_opts, opts)
5555
expect(result[:exitcode]).to eq(-1), OctocatalogDiff::Integration.format_exception(result)
56-
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Util::Catalogs::CatalogError')
56+
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Errors::CatalogError')
5757
expect(result[:exception].message).to match(/OpenSSL::SSL::SSLError/)
5858
end
5959

@@ -71,7 +71,7 @@
7171
opts = { argv: args, spec_repo: 'tiny-repo' }
7272
result = OctocatalogDiff::Integration.integration_with_puppetdb(s_opts, opts)
7373
expect(result[:exitcode]).to eq(-1), OctocatalogDiff::Integration.format_exception(result)
74-
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Util::Catalogs::CatalogError')
74+
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Errors::CatalogError')
7575
expect(result[:exception].message).to match(/OpenSSL::SSL::SSLError/)
7676
end
7777
end
@@ -88,7 +88,7 @@
8888
it 'should fail to connect to authenticated puppetdb with no client cert', retry: 3 do
8989
opts = { argv: ['-n', 'rspec-node.github.net'], spec_repo: 'tiny-repo' }
9090
result = OctocatalogDiff::Integration.integration_with_puppetdb(s_opts, opts)
91-
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Util::Catalogs::CatalogError')
91+
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Errors::CatalogError')
9292
expect(result[:exception].message).to match(/OpenSSL::SSL::SSLError/)
9393
end
9494

@@ -127,7 +127,7 @@
127127
opts = { argv: arg, spec_repo: 'tiny-repo' }
128128
result = OctocatalogDiff::Integration.integration_with_puppetdb(s_opts, opts)
129129
expect(result[:exitcode]).to eq(-1), OctocatalogDiff::Integration.format_exception(result)
130-
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Util::Catalogs::CatalogError')
130+
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Errors::CatalogError')
131131
expect(result[:exception].message).to match(/OpenSSL::PKey::RSAError/)
132132
end
133133

@@ -140,7 +140,7 @@
140140
opts = { argv: arg, spec_repo: 'tiny-repo' }
141141
result = OctocatalogDiff::Integration.integration_with_puppetdb(s_opts, opts)
142142
expect(result[:exitcode]).to eq(-1), OctocatalogDiff::Integration.format_exception(result)
143-
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Util::Catalogs::CatalogError')
143+
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Errors::CatalogError')
144144
expect(result[:exception].message).to match(/OpenSSL::PKey::RSAError/)
145145
end
146146
end

spec/octocatalog-diff/integration/puppetmaster_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def self.response(method, uri, _headers, body)
157157
}
158158
result = OctocatalogDiff::Integration.integration(opts)
159159
expect(result[:exitcode]).to eq(-1)
160-
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Util::Catalogs::CatalogError')
160+
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Errors::CatalogError')
161161
expect(result[:exception].message).to match(/OpenSSL::SSL::SSLError/)
162162
end
163163

@@ -174,7 +174,7 @@ def self.response(method, uri, _headers, body)
174174
}
175175
result = OctocatalogDiff::Integration.integration(opts)
176176
expect(result[:exitcode]).to eq(-1)
177-
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Util::Catalogs::CatalogError')
177+
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Errors::CatalogError')
178178
expect(result[:exception].message).to match(/foobaz.local: 404/)
179179
end
180180

0 commit comments

Comments
 (0)