Skip to content

Commit

Permalink
Refactor spec
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyCTHsu committed Aug 29, 2024
1 parent c67c666 commit b6176de
Showing 1 changed file with 7 additions and 21 deletions.
28 changes: 7 additions & 21 deletions spec/datadog/core/telemetry/logging_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,28 +130,14 @@
end

it 'returns redacted stack trace' do
gem_root = Datadog::Core::Telemetry::Logging::DatadogStackTrace::GEM_ROOT

exception = StandardError.new('Yo!')
exception.set_backtrace(
[
"#{gem_root}/lib/datadog/core/telemetry/logging.rb:1 in `report`",
'/foo/bar/baz.rb:1 in `baz`',
'/foo/bar.rb:1 in `bar`',
'/foo.rb:1 in `foo`',
]
)

result = described_class.from(exception)
begin
raise 'Invalid token: p@ssw0rd'
rescue StandardError => e
result = described_class.from(e)
end

expect(result).to eq(
[
'/lib/datadog/core/telemetry/logging.rb:1 in `report`',
'REDACTED',
'REDACTED',
'REDACTED'
].join(',')
)
expect(result).to start_with('/spec/datadog/core/telemetry/logging_spec.rb')
expect(result).to end_with('REDACTED')
end
end
end

0 comments on commit b6176de

Please sign in to comment.