Elixir 1.19: Fix ConfigDBTest regex tests
It is not possible match regexes anymore as this worked by accident
previously. Instead, at least check that the sources of the regex (the
regex itself) match.
Notice the +1 difference in the regex Reference below.
1) test to_elixir_types/1 complex keyword with sigil (Pleroma.ConfigDBTest)
test/pleroma/config_db_test.exs:460
Assertion with == failed
code: assert ConfigDB.to_elixir_types([
%{"tuple" => [":federated_timeline_removal", []]},
%{"tuple" => [":reject", ["~r/comp[lL][aA][iI][nN]er/"]]},
%{"tuple" => [":replace", []]}
]) == [federated_timeline_removal: [], reject: [~r/comp[lL][aA][iI][nN]er/], replace: []]
left: [federated_timeline_removal: [], reject: [%Regex{opts: [], re_pattern: {:re_pattern, 0, 0, 0, #Reference<0.230935836.591265794.259515>}, source: "comp[lL][aA][iI][nN]er"}], replace: []]
right: [federated_timeline_removal: [], reject: [%Regex{opts: [], re_pattern: {:re_pattern, 0, 0, 0, #Reference<0.230935836.591265794.259516>}, source: "comp[lL][aA][iI][nN]er"}], replace: []]
stacktrace:
test/pleroma/config_db_test.exs:461: (test)
This commit is contained in:
parent
531041041a
commit
bf86768e88
1 changed files with 8 additions and 8 deletions
|
|
@ -273,24 +273,24 @@ defmodule Pleroma.ConfigDBTest do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "sigil" do
|
test "sigil" do
|
||||||
assert ConfigDB.to_elixir_types("~r[comp[lL][aA][iI][nN]er]") == ~r/comp[lL][aA][iI][nN]er/
|
assert ConfigDB.to_elixir_types("~r[comp[lL][aA][iI][nN]er]").source == ~r/comp[lL][aA][iI][nN]er/.source
|
||||||
end
|
end
|
||||||
|
|
||||||
test "link sigil" do
|
test "link sigil" do
|
||||||
assert ConfigDB.to_elixir_types("~r/https:\/\/example.com/") == ~r/https:\/\/example.com/
|
assert ConfigDB.to_elixir_types("~r/https:\/\/example.com/").source == ~r/https:\/\/example.com/.source
|
||||||
end
|
end
|
||||||
|
|
||||||
test "link sigil with um modifiers" do
|
test "link sigil with um modifiers" do
|
||||||
assert ConfigDB.to_elixir_types("~r/https:\/\/example.com/um") ==
|
assert ConfigDB.to_elixir_types("~r/https:\/\/example.com/um").source ==
|
||||||
~r/https:\/\/example.com/um
|
~r/https:\/\/example.com/um.source
|
||||||
end
|
end
|
||||||
|
|
||||||
test "link sigil with i modifier" do
|
test "link sigil with i modifier" do
|
||||||
assert ConfigDB.to_elixir_types("~r/https:\/\/example.com/i") == ~r/https:\/\/example.com/i
|
assert ConfigDB.to_elixir_types("~r/https:\/\/example.com/i").source == ~r/https:\/\/example.com/i.source
|
||||||
end
|
end
|
||||||
|
|
||||||
test "link sigil with s modifier" do
|
test "link sigil with s modifier" do
|
||||||
assert ConfigDB.to_elixir_types("~r/https:\/\/example.com/s") == ~r/https:\/\/example.com/s
|
assert ConfigDB.to_elixir_types("~r/https:\/\/example.com/s").source == ~r/https:\/\/example.com/s.source
|
||||||
end
|
end
|
||||||
|
|
||||||
test "raise if valid delimiter not found" do
|
test "raise if valid delimiter not found" do
|
||||||
|
|
@ -460,11 +460,11 @@ defmodule Pleroma.ConfigDBTest do
|
||||||
test "complex keyword with sigil" do
|
test "complex keyword with sigil" do
|
||||||
assert ConfigDB.to_elixir_types([
|
assert ConfigDB.to_elixir_types([
|
||||||
%{"tuple" => [":federated_timeline_removal", []]},
|
%{"tuple" => [":federated_timeline_removal", []]},
|
||||||
%{"tuple" => [":reject", ["~r/comp[lL][aA][iI][nN]er/"]]},
|
%{"tuple" => [":reject", [~r/comp[lL][aA][iI][nN]er/.source]]},
|
||||||
%{"tuple" => [":replace", []]}
|
%{"tuple" => [":replace", []]}
|
||||||
]) == [
|
]) == [
|
||||||
federated_timeline_removal: [],
|
federated_timeline_removal: [],
|
||||||
reject: [~r/comp[lL][aA][iI][nN]er/],
|
reject: [~r/comp[lL][aA][iI][nN]er/.source],
|
||||||
replace: []
|
replace: []
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue