fix for subgroup tuple

added settings for swoosh adapters local
This commit is contained in:
Alexander 2019-12-20 10:22:53 +03:00 committed by Alexander Strizhakov
parent 063ab6d911
commit cda2c1fc63
No known key found for this signature in database
GPG key ID: 022896A53AEF1381
3 changed files with 37 additions and 1 deletions

View file

@ -238,7 +238,8 @@
Swoosh.Adapters.AmazonSES, Swoosh.Adapters.AmazonSES,
Swoosh.Adapters.Dyn, Swoosh.Adapters.Dyn,
Swoosh.Adapters.SocketLabs, Swoosh.Adapters.SocketLabs,
Swoosh.Adapters.Gmail Swoosh.Adapters.Gmail,
Swoosh.Adapters.Local
] ]
}, },
%{ %{
@ -449,6 +450,26 @@
} }
] ]
}, },
%{
group: :swoosh,
type: :group,
description: "`Swoosh.Adapters.Local` adapter specific settings",
children: [
%{
group: {:subgroup, Swoosh.Adapters.Local},
key: :serve_mailbox,
type: :boolean,
description: "Run the preview server together as part of your app"
},
%{
group: {:subgroup, Swoosh.Adapters.Local},
key: :preview_port,
type: :integer,
description: "The preview server port",
suggestions: [4001]
}
]
},
%{ %{
group: :pleroma, group: :pleroma,
key: :uri_schemes, key: :uri_schemes,

View file

@ -58,15 +58,23 @@ defp format_child(%{suggestions: suggestions} = entity) do
entity entity
|> Map.put(:suggestions, format_suggestions(suggestions)) |> Map.put(:suggestions, format_suggestions(suggestions))
|> format_key() |> format_key()
|> format_group()
|> format_children() |> format_children()
end end
defp format_child(entity) do defp format_child(entity) do
entity entity
|> format_key() |> format_key()
|> format_group()
|> format_children() |> format_children()
end end
defp format_group(%{group: group} = entity) do
Map.put(entity, :group, format_suggestion(group))
end
defp format_group(entity), do: entity
defp atom_to_string(entity) when is_binary(entity), do: entity defp atom_to_string(entity) when is_binary(entity), do: entity
defp atom_to_string(entity) when is_atom(entity), do: inspect(entity) defp atom_to_string(entity) when is_atom(entity), do: inspect(entity)

View file

@ -207,5 +207,12 @@ test "key as string subchild" do
child = Enum.at(children, 7) child = Enum.at(children, 7)
assert child[:key] == "application/xml" assert child[:key] == "application/xml"
end end
test "subgroup with module name" do
[%{children: children} | _] = Generator.convert_to_strings(@descriptions)
%{group: subgroup} = Enum.at(children, 6)
assert subgroup == {":subgroup", "Swoosh.Adapters.SMTP"}
end
end end
end end