Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement assert_matches with expanded expressions support in match assertions #5024

Merged
merged 13 commits into from
Jan 31, 2025
Merged
3 changes: 2 additions & 1 deletion .formatter.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"{config,lib,test,extra}/**/*.{heex,ex,exs}",
"priv/*/seeds.exs",
"storybook/**/*.exs"
]
],
locals_without_parens: [assert_matches: 1]
]
Original file line number Diff line number Diff line change
Expand Up @@ -355,16 +355,17 @@ defmodule PlausibleWeb.Api.Internal.SegmentsControllerTest do
})
|> json_response(200)

assert %{
"name" => "Some segment",
"type" => "#{unquote(type)}",
"segment_data" => %{"filters" => [["is", "visit:entry_page", ["/blog"]]]},
"owner_id" => user.id
} == Map.drop(response, ["id", "inserted_at", "updated_at"])
assert_matches ^strict_map(%{
"id" => ^any(:pos_integer),
"name" => "Some segment",
"type" => ^"#{unquote(type)}",
"segment_data" =>
^strict_map(%{"filters" => [["is", "visit:entry_page", ["/blog"]]]}),
"owner_id" => ^user.id,
"inserted_at" => ^any(:iso8601_naive_datetime),
"updated_at" => ^any(:iso8601_naive_datetime)
}) = response

assert is_integer(response["id"])
assert is_binary(response["inserted_at"])
assert is_binary(response["updated_at"])
assert response["inserted_at"] == response["updated_at"]

verify_segment_in_db(%Plausible.Segments.Segment{
Expand Down
Loading
Loading