Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
p committed Nov 11, 2024
1 parent e292b1a commit 785b86b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'spec_helper'
require 'datadog/di/spec_helper'

class EverythingFromRemoteConfigSpecTestClass
def target_method
Expand Down Expand Up @@ -81,8 +82,7 @@ def target_method
end

after do
probe_manager.clear_hooks
probe_manager.close
component.shutdown!
end

let(:agent_settings) do
Expand Down Expand Up @@ -217,8 +217,9 @@ def do_rc
notify_payload = if env.path == '/debugger/v1/diagnostics'
JSON.parse(env.form.fetch('event').io.read, symbolize_names: true)
else
env.form
JSON.parse(env.body)
end
expect(notify_payload).to be_a(Array)
notify_payload.each do |payload|
payloads << payload.merge(path: env.path)
end
Expand All @@ -242,7 +243,7 @@ def do_rc
expect(payloads.length).to eq 1

received_payload = payloads.first
expect(received_payload).to match(expected_received_payload)
expect(order_hash_keys(received_payload)).to match(order_hash_keys(expected_received_payload))

expect(probe_manager.pending_probes.length).to eq 1
end
Expand Down Expand Up @@ -295,7 +296,7 @@ def assert_received_and_installed
expect(emitting_payload).to match(expected_emitting_payload)

snapshot_payload = payloads.shift
expect(snapshot_payload).to match(expected_snapshot_payload)
expect(order_hash_keys(snapshot_payload)).to match(deep_stringify_keys(order_hash_keys(expected_snapshot_payload)))
end
end
end
Expand Down
15 changes: 15 additions & 0 deletions spec/datadog/di/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,21 @@ def without_code_tracking
end

module InstanceMethods
def order_hash_keys(hash)
Hash[hash.keys.map do |key|
[key.to_s, hash[key]]
end]
end

def deep_stringify_keys(hash)
if Hash === hash
Hash[hash.map do |key, value|
[key.to_s, deep_stringify_keys(value)]
end]
else
hash
end
end
end
end

Expand Down

0 comments on commit 785b86b

Please sign in to comment.