Skip to content

Commit bafc777

Browse files
author
Kevin Paulisse
committed
Error rename and coverage for bootstrap class
1 parent 7a6199e commit bafc777

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

lib/octocatalog-diff/catalog-util/bootstrap.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def self.git_checkout(logger, dir_opts)
101101
logger.debug("Begin git checkout #{dir_opts[:basedir]}:#{dir_opts[:branch]} -> #{dir_opts[:path]}")
102102
OctocatalogDiff::CatalogUtil::Git.check_out_git_archive(dir_opts.merge(logger: logger))
103103
logger.debug("Success git checkout #{dir_opts[:basedir]}:#{dir_opts[:branch]} -> #{dir_opts[:path]}")
104-
rescue OctocatalogDiff::CatalogUtil::Git::GitCheckoutError => exc
104+
rescue OctocatalogDiff::Errors::GitCheckoutError => exc
105105
logger.error("Git checkout error: #{exc}")
106106
raise OctocatalogDiff::Errors::BootstrapError, exc
107107
end

spec/octocatalog-diff/tests/catalog-util/bootstrap_spec.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,4 +164,29 @@
164164
end
165165
end
166166
end
167+
168+
describe '#git_checkout' do
169+
context 'with successful git checkout' do
170+
it 'should log success messages' do
171+
expect(OctocatalogDiff::CatalogUtil::Git).to receive(:check_out_git_archive)
172+
logger, logger_str = OctocatalogDiff::Spec.setup_logger
173+
opts = { basedir: '/tmp/foo', branch: 'foo', path: '/tmp/bar' }
174+
described_class.git_checkout(logger, opts)
175+
expect(logger_str.string).to match(%r{Begin git checkout /tmp/foo:foo -> /tmp/bar})
176+
expect(logger_str.string).to match(%r{Success git checkout /tmp/foo:foo -> /tmp/bar})
177+
end
178+
end
179+
180+
context 'with failed git checkout' do
181+
it 'should log error messages and raise OctocatalogDiff::Errors::BootstrapError' do
182+
expect(OctocatalogDiff::CatalogUtil::Git).to receive(:check_out_git_archive)
183+
.and_raise(OctocatalogDiff::Errors::GitCheckoutError, 'Oopsie')
184+
logger, logger_str = OctocatalogDiff::Spec.setup_logger
185+
opts = { basedir: '/tmp/foo', branch: 'foo', path: '/tmp/bar' }
186+
expect { described_class.git_checkout(logger, opts) }.to raise_error(OctocatalogDiff::Errors::BootstrapError)
187+
expect(logger_str.string).to match(%r{Begin git checkout /tmp/foo:foo -> /tmp/bar})
188+
expect(logger_str.string).to match(/Git checkout error: Oopsie/)
189+
end
190+
end
191+
end
167192
end

0 commit comments

Comments
 (0)