test: add regression tests that fail (#71)

This commit is contained in:
Igor Barakaiev 2024-08-05 06:16:13 +03:00 committed by GitHub
parent 79ae2d653b
commit e2a1682d87
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -136,6 +136,56 @@ defmodule Igniter.Project.ConfigTest do
"""
end
@tag :regression
test "it merges with 3 arg version of existing config with the config set to []" do
%{rewrite: rewrite} =
Igniter.new()
|> Igniter.create_new_elixir_file("config/fake.exs", """
import Config
config :foo, SomeModule, []
""")
|> Igniter.Project.Config.configure(
"fake.exs",
:foo,
[SomeModule, :level1, :level2],
:value
)
config_file = Rewrite.source!(rewrite, "config/fake.exs")
assert Source.get(config_file, :content) == """
import Config
config :foo, SomeModule, level1: [level2: :value]
"""
end
@tag :regression
test "it merges with 3 arg version of existing config with the config set to [] and the path is one level deeper than existing" do
%{rewrite: rewrite} =
Igniter.new()
|> Igniter.create_new_elixir_file("config/fake.exs", """
import Config
config :foo, SomeModule, [level1: []]
""")
|> Igniter.Project.Config.configure(
"fake.exs",
:foo,
[SomeModule, :level1, :level2, :level3],
:value
)
config_file = Rewrite.source!(rewrite, "config/fake.exs")
assert Source.get(config_file, :content) == """
import Config
config :foo, SomeModule, level1: [level2: [level3: :value]]
"""
end
test "it merges with 3 arg version of existing config with a single path item" do
%{rewrite: rewrite} =
Igniter.new()