Skip to content

Commit

Permalink
Add test for serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
ananthakumaran committed Nov 21, 2024
1 parent 6d52047 commit b4aa08b
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/exq_scheduler/serializer_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
defmodule ExqScheduler.SerializerTest do
use ExUnit.Case
import ExqScheduler.Serializer

test "encode" do
assert stable_encode!(%{"a" => 1}) == ~S({"a":1})
assert stable_encode!(%{"b" => 1, "a" => 1}) == ~S({"a":1,"b":1})

size = 100

map =
for n <- 1..size, do: {"element_#{String.pad_leading(to_string(n), 3, "0")}", n}, into: %{}

json =
for n <- 1..size,
do: ~s("element_#{String.pad_leading(to_string(n), 3, "0")}":#{n})

assert stable_encode!(map) == "{" <> Enum.join(json, ",") <> "}"
end
end

0 comments on commit b4aa08b

Please sign in to comment.