Skip to content

Commit

Permalink
Refactor broken tests
Browse files Browse the repository at this point in the history
Signed-off-by: Gavin Didrichsen <gavin.didrichsen@gmail.com>
  • Loading branch information
gavindidrichsen committed Jan 15, 2025
1 parent c468f37 commit d6fba02
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions spec/unit/applicator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,18 @@
.with('ruby', /bolt_catalog/, 'compile', stdin_data: input.merge(target_hash).to_json)
.and_return(['{}', logs.map(&:to_json).join("\n"), double(:status, success?: true)])
expect(applicator.compile(target, input)).to eq({})
expect(@log_output.readlines).to eq(
[
"DEBUG Bolt::Executor : Started with 1 max thread(s)\n",
"DEBUG Bolt::Inventory::Inventory : Did not find config for #{target.uri} in inventory\n",
"TRACE Bolt::Applicator : #{target.uri}: A message\n",
"DEBUG Bolt::Applicator : #{target.uri}: Stuff happened\n"
]
)

# check that each expected line is in the actual output; sometimes different systems include other lines
expected_lines = [
"DEBUG Bolt::Executor : Started with 1 max thread(s)",
"DEBUG Bolt::Inventory::Inventory : Did not find config for #{target.uri} in inventory",
"TRACE Bolt::Applicator : #{target.uri}: A message",
"DEBUG Bolt::Applicator : #{target.uri}: Stuff happened"
]
actual_lines = @log_output.readlines.map(&:chomp) # Remove any newline characters
expected_lines.each do |line|
expect(actual_lines).to include(line)
end
end

context 'with Puppet mocked' do
Expand Down

0 comments on commit d6fba02

Please sign in to comment.