Skip to content

Commit ff89208

Browse files
author
Kevin Paulisse
committed
Add test covering version display
1 parent d05c301 commit ff89208

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

  • lib/octocatalog-diff/catalog-diff
  • spec/octocatalog-diff/tests/catalog-diff

lib/octocatalog-diff/catalog-diff/cli.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def self.setup_logger(logger, options, argv_save)
166166
logger.level = Logger::ERROR if options[:quiet]
167167

168168
# Some debugging information up front
169-
version_display = "@#{ENV['OCTOCATALOG_DIFF_CUSTOM_VERSION']}" || VERSION
169+
version_display = ENV['OCTOCATALOG_DIFF_CUSTOM_VERSION'] || VERSION
170170
logger.debug "Running octocatalog-diff #{version_display} with ruby #{RUBY_VERSION}"
171171
logger.debug "Command line arguments: #{argv_save.inspect}"
172172
logger.debug "Running on host #{Socket.gethostname} (#{RUBY_PLATFORM})"

spec/octocatalog-diff/tests/catalog-diff/cli_spec.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,37 @@
115115
end
116116
end
117117

118+
describe '#setup_logger' do
119+
context 'with custom version specified in environment' do
120+
before(:each) do
121+
ENV['OCTOCATALOG_DIFF_CUSTOM_VERSION'] = '@d05c30152c897219367d586414ccb1f651ab7221'
122+
end
123+
124+
after(:each) do
125+
ENV.delete 'OCTOCATALOG_DIFF_CUSTOM_VERSION'
126+
end
127+
128+
it 'should log custom version' do
129+
logger, logger_str = OctocatalogDiff::Spec.setup_logger
130+
described_class.setup_logger(logger, { debug: true }, [{ foo: 'bar' }])
131+
expect(logger_str.string).to match(/Running octocatalog-diff @d05c30152c897219367d586414ccb1f651ab7221 with ruby/)
132+
end
133+
end
134+
135+
context 'with default version' do
136+
before(:each) do
137+
ENV.delete 'OCTOCATALOG_DIFF_CUSTOM_VERSION'
138+
end
139+
140+
it 'should log current version' do
141+
logger, logger_str = OctocatalogDiff::Spec.setup_logger
142+
described_class.setup_logger(logger, { debug: true }, [{ foo: 'bar' }])
143+
version = described_class::VERSION
144+
expect(logger_str.string).to match(/Running octocatalog-diff #{version} with ruby/)
145+
end
146+
end
147+
end
148+
118149
describe '#setup_fact_overrides' do
119150
it 'should make no adjustments when there are no fact overrides' do
120151
options = {}

0 commit comments

Comments
 (0)