diff --git a/apps/datagouvfr/test/datagouvfr/client/discussions_test.exs b/apps/datagouvfr/test/datagouvfr/client/discussions_test.exs index 894a2435e2..dde0e495f7 100644 --- a/apps/datagouvfr/test/datagouvfr/client/discussions_test.exs +++ b/apps/datagouvfr/test/datagouvfr/client/discussions_test.exs @@ -21,7 +21,12 @@ defmodule Datagouvfr.Client.DiscussionTest do {"content-type", "application/json"} ] - assert body == ~s({"comment":"#{comment}","subject":{"class":"Dataset","id":"#{datagouv_id}"},"title":"#{title}"}) + assert Jason.decode!(body) == %{ + "comment" => comment, + "subject" => %{"class" => "Dataset", "id" => datagouv_id}, + "title" => title + } + json(%{"title" => title, "discussion" => [%{"content" => comment}]}, status: 201) end) diff --git a/apps/shared/test/validation/gbfs_validator_test.exs b/apps/shared/test/validation/gbfs_validator_test.exs index c41515e5ba..4b134e53c1 100644 --- a/apps/shared/test/validation/gbfs_validator_test.exs +++ b/apps/shared/test/validation/gbfs_validator_test.exs @@ -50,17 +50,25 @@ defmodule GBFSValidatorTest do assert logs =~ "impossible to query GBFS Validator" end - test "can encode summary" do - assert """ - {"errors_count":0,"has_errors":false,"validator":"validator_module","validator_version":"31c5325","version_detected":"1.1","version_validated":"1.1"}\ - """ == - Jason.encode!(%Summary{ - errors_count: 0, - has_errors: false, - version_detected: "1.1", - version_validated: "1.1", - validator_version: "31c5325", - validator: :validator_module - }) + test "can encode and decode summary" do + encoded_summary = + Jason.encode!(%Summary{ + errors_count: 0, + has_errors: false, + version_detected: "1.1", + version_validated: "1.1", + validator_version: "31c5325", + validator: :validator_module + }) + + assert Jason.decode!(encoded_summary) == %{ + "errors_count" => 0, + "has_errors" => false, + # NOTE: the serialized atom does not come back as an atom + "validator" => "validator_module", + "validator_version" => "31c5325", + "version_detected" => "1.1", + "version_validated" => "1.1" + } end end diff --git a/apps/transport/lib/jobs/gtfs_rt_metadata.ex b/apps/transport/lib/jobs/gtfs_rt_metadata.ex index 6f60d2528f..3b0abb50f6 100644 --- a/apps/transport/lib/jobs/gtfs_rt_metadata.ex +++ b/apps/transport/lib/jobs/gtfs_rt_metadata.ex @@ -72,7 +72,10 @@ defmodule Transport.Jobs.GTFSRTMetadataJob do ["service_alerts", "vehicle_positions"] """ def present_entities(count_entities) do - count_entities |> Map.filter(fn {_, v} -> v > 0 end) |> Enum.map(fn {k, _} -> Atom.to_string(k) end) + count_entities + |> Map.filter(fn {_, v} -> v > 0 end) + |> Enum.map(fn {k, _} -> Atom.to_string(k) end) + |> Enum.sort() end @spec process_feed({:error, any} | {:ok, TransitRealtime.FeedMessage.t()}, DB.Resource.t()) :: any diff --git a/apps/transport/test/transport_web/live_views/cache_live_test.exs b/apps/transport/test/transport_web/live_views/cache_live_test.exs index 48e927702a..a78802d603 100644 --- a/apps/transport/test/transport_web/live_views/cache_live_test.exs +++ b/apps/transport/test/transport_web/live_views/cache_live_test.exs @@ -44,6 +44,6 @@ defmodule TransportWeb.Backoffice.CacheLiveTest do %{"Clé" => "foo", "TTL" => "Pas de TTL"} ] = extract_data_from_html(render(view)) - assert_in_delta ttl |> String.replace([" ", "ms"], "") |> String.to_integer(), ttl_ms, 10 + assert_in_delta ttl |> String.replace([" ", "ms"], "") |> String.to_integer(), ttl_ms, 30 end end diff --git a/apps/unlock/test/enforce_ttl_test.exs b/apps/unlock/test/enforce_ttl_test.exs index 9f565371e7..c496c7360a 100644 --- a/apps/unlock/test/enforce_ttl_test.exs +++ b/apps/unlock/test/enforce_ttl_test.exs @@ -45,7 +45,7 @@ defmodule Unlock.EnforceTTLTest do cache_put("no_prefix") # initially, the list of proxy cache keys should include only 2 entries - assert ["resource:with_ttl", "resource:no_ttl"] == cache_keys() + assert ["resource:no_ttl", "resource:with_ttl"] == cache_keys() |> Enum.sort() # this is expected to remove bogus entries (the ones without a TTL), # which would otherwise remain "available but stale" forever diff --git a/apps/unlock/test/shared_test.exs b/apps/unlock/test/shared_test.exs index bb6bdb0d38..a9c3e07bd0 100644 --- a/apps/unlock/test/shared_test.exs +++ b/apps/unlock/test/shared_test.exs @@ -36,6 +36,6 @@ defmodule Unlock.SharedTest do cache_put(cache_key("no_ttl")) cache_put("no_prefix") - assert ["resource:with_ttl", "resource:no_ttl"] == cache_keys() + assert ["resource:no_ttl", "resource:with_ttl"] == cache_keys() |> Enum.sort() end end