From b9a2a574f533b2cd8fffc0c13418d1d06f207cf8 Mon Sep 17 00:00:00 2001 From: Parker Selbert Date: Tue, 31 Oct 2023 08:27:15 -0500 Subject: [PATCH] Restore comparing dumped json without order issue --- test/honeybadger/json_test.exs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/test/honeybadger/json_test.exs b/test/honeybadger/json_test.exs index 995e69f..5e5629f 100644 --- a/test/honeybadger/json_test.exs +++ b/test/honeybadger/json_test.exs @@ -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