Accept two element tuple list
Opened this issue · 1 comments
prodis commented
https://hexdocs.pm/elixir/Map.html#to_list/1
BoFH.Providers.EAN.Params.BookReservationTest
* test to_xml_payload/1 converts book reservation params to a string XML representation of payload (94.8ms)
1) test to_xml_payload/1 converts book reservation params to a string XML representation of payload (BoFH.Providers.EAN.Params.BookReservationTest)
test/params/book_reservation_test.exs:82
** (FunctionClauseError) no function clause matching in XmlBuilder.format/3
The following arguments were given to XmlBuilder.format/3:
# 1
{"affiliateConfirmationId", "itidx1eff"}
# 2
1
# 3
[]
Attempted function clauses (showing 10 out of 12):
defp format(:xml_decl, 0, options)
defp format({:doctype, {:system, name, system}}, 0, _options)
defp format({:doctype, {:public, name, public, system}}, 0, _options)
defp format(string, level, options) when is_bitstring(string)
defp format(list, level, options) when is_list(list)
defp format({nil, nil, name}, level, options) when is_bitstring(name)
defp format({name, attrs, content}, level, options) when (attrs == nil or is_map(attrs) and map_size(attrs) == 0 or (attrs == nil or is_list(attrs) and length(attrs) == 0)) and (content == nil or is_list(content) and length(content) == 0)
defp format({name, attrs, content}, level, options) when content == nil or is_list(content) and length(content) == 0
defp format({name, attrs, content}, level, options) when (attrs == nil or is_map(attrs) and map_size(attrs) == 0 or (attrs == nil or is_list(attrs) and length(attrs) == 0)) and not(is_list(content))
defp format({name, attrs, content}, level, options) when (attrs == nil or is_map(attrs) and map_size(attrs) == 0 or (attrs == nil or is_list(attrs) and length(attrs) == 0)) and is_list(content)
code: assert Subject.to_xml_payload(@params) == expected_xml_payload
stacktrace:
(xml_builder) lib/xml_builder.ex:220: XmlBuilder.format/3
(elixir) lib/enum.ex:1386: anonymous fn/4 in Enum.map_join/3
(elixir) lib/enum.ex:1925: Enum."-map_join/3-lists^foldl/2-0-"/3
(elixir) lib/enum.ex:1925: Enum.map_join/3
(xml_builder) lib/xml_builder.ex:285: XmlBuilder.format_content/3
(xml_builder) lib/xml_builder.ex:253: XmlBuilder.format/3
(xml_builder) lib/xml_builder.ex:218: XmlBuilder.generate/2
test/params/book_reservation_test.exs:153: (test)
prodis commented
iex(9)> {:root, nil, [one: 1, two: "2", none: ""]} |> XmlBuilder.generate
** (FunctionClauseError) no function clause matching in XmlBuilder.format/3
The following arguments were given to XmlBuilder.format/3:
# 1
{:one, 1}
# 2
1
# 3
[]
Attempted function clauses (showing 10 out of 12):
defp format(:xml_decl, 0, options)
defp format({:doctype, {:system, name, system}}, 0, _options)
defp format({:doctype, {:public, name, public, system}}, 0, _options)
defp format(string, level, options) when is_bitstring(string)
defp format(list, level, options) when is_list(list)
defp format({nil, nil, name}, level, options) when is_bitstring(name)
defp format({name, attrs, content}, level, options) when (attrs == nil or is_map(attrs) and map_size(attrs) == 0 or (attrs == nil or is_list(attrs) and length(attrs) == 0)) and (content == nil or is_list(content) and length(content) == 0)
defp format({name, attrs, content}, level, options) when content == nil or is_list(content) and length(content) == 0
defp format({name, attrs, content}, level, options) when (attrs == nil or is_map(attrs) and map_size(attrs) == 0 or (attrs == nil or is_list(attrs) and length(attrs) == 0)) and not(is_list(content))
defp format({name, attrs, content}, level, options) when (attrs == nil or is_map(attrs) and map_size(attrs) == 0 or (attrs == nil or is_list(attrs) and length(attrs) == 0)) and is_list(content)
(xml_builder) lib/xml_builder.ex:220: XmlBuilder.format/3
(elixir) lib/enum.ex:1386: anonymous fn/4 in Enum.map_join/3
(elixir) lib/enum.ex:1925: Enum."-map_join/3-lists^foldl/2-0-"/3
(elixir) lib/enum.ex:1925: Enum.map_join/3
(xml_builder) lib/xml_builder.ex:285: XmlBuilder.format_content/3
(xml_builder) lib/xml_builder.ex:253: XmlBuilder.format/3
(xml_builder) lib/xml_builder.ex:218: XmlBuilder.generate/2
iex(9)> {:root, nil, [one: 1, two: "2", none: ""]} |> XmlBuilder.element
{:root, nil, [{:one, nil, 1}, {:two, nil, "2"}, {:none, nil, ""}]}
iex(10)> {:root, nil, [one: 1, two: "2", none: ""]} |> XmlBuilder.element |> XmlBuilder.generate
"<root>\n <one>1</one>\n <two>2</two>\n <none></none>\n</root>"
iex(11)>