Skip to content

Commit

Permalink
Restore comparing dumped json without order issue
Browse files Browse the repository at this point in the history
  • Loading branch information
sorentwo committed Nov 1, 2023
1 parent 4eabbd9 commit 00617bd
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions test/honeybadger/json_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,19 @@ defmodule Honeybadger.JSONTest do
test "encodes notice when context has structs" do
error = %RuntimeError{message: "oops"}
struct = %Request{ip: "0.0.0.0"}
map = Map.from_struct(struct)

assert {:ok, _json} =
error
|> Notice.new(%{context: %{a: struct, b: [struct], c: {struct, struct}}}, [])
|> JSON.encode()
{:ok, custom_encoded} =
error
|> Notice.new(%{context: %{a: struct, b: [struct], c: {struct, struct}}}, [])
|> JSON.encode()

{:ok, jason_encoded} =
error
|> Notice.new(%{context: %{a: map, b: [map], c: [map, map]}}, [])
|> Jason.encode()

assert Jason.decode!(custom_encoded) == Jason.decode!(jason_encoded)
end

test "handles values requring inspection" do
Expand Down

0 comments on commit 00617bd

Please sign in to comment.