mirror of
https://github.com/ash-project/igniter.git
synced 2024-09-19 21:12:54 +12:00
test: add failing config tests (#77)
This commit is contained in:
parent
ede41d3c12
commit
ccdbfee957
1 changed files with 106 additions and 0 deletions
|
@ -215,6 +215,43 @@ defmodule Igniter.Project.ConfigTest do
|
||||||
"""
|
"""
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@tag :regression
|
||||||
|
test "it merges with 2 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 :level1,
|
||||||
|
version: "1.0.0",
|
||||||
|
level2: []
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|> Igniter.Project.Config.configure(
|
||||||
|
"fake.exs",
|
||||||
|
:level1,
|
||||||
|
[:level2, :level3],
|
||||||
|
1
|
||||||
|
)
|
||||||
|
|
||||||
|
config_file = Rewrite.source!(rewrite, "config/fake.exs")
|
||||||
|
|
||||||
|
assert Source.get(config_file, :content) ==
|
||||||
|
"""
|
||||||
|
import Config
|
||||||
|
|
||||||
|
config :level1,
|
||||||
|
version: "1.0.0",
|
||||||
|
level2: [
|
||||||
|
level3: [
|
||||||
|
args: 1
|
||||||
|
]
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
end
|
||||||
|
|
||||||
test "it merges with 3 arg version of existing config with a single path item" do
|
test "it merges with 3 arg version of existing config with a single path item" do
|
||||||
%{rewrite: rewrite} =
|
%{rewrite: rewrite} =
|
||||||
Igniter.new()
|
Igniter.new()
|
||||||
|
@ -313,6 +350,75 @@ defmodule Igniter.Project.ConfigTest do
|
||||||
"""
|
"""
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@tag :regression
|
||||||
|
test "arbitrary data structures can be used as values" do
|
||||||
|
%{rewrite: rewrite} =
|
||||||
|
Igniter.new()
|
||||||
|
|> Igniter.create_new_elixir_file("config/fake.exs", """
|
||||||
|
import Config
|
||||||
|
config :level1, :level2, level3: [{"hello", "world"}]
|
||||||
|
""")
|
||||||
|
|> Igniter.Project.Config.configure("fake.exs", :level1, [:level2, :level3], [
|
||||||
|
{"hello1", "world1"}
|
||||||
|
])
|
||||||
|
|
||||||
|
config_file = Rewrite.source!(rewrite, "config/fake.exs")
|
||||||
|
|
||||||
|
assert Source.get(config_file, :content) == """
|
||||||
|
import Config
|
||||||
|
config :level1, :level2, level3: [{"hello1", "world1"}]
|
||||||
|
"""
|
||||||
|
end
|
||||||
|
|
||||||
|
@tag :regression
|
||||||
|
test "quoted code can be used as values" do
|
||||||
|
%{rewrite: rewrite} =
|
||||||
|
Igniter.new()
|
||||||
|
|> Igniter.create_new_elixir_file(
|
||||||
|
"config/fake.exs",
|
||||||
|
"""
|
||||||
|
import Config
|
||||||
|
|
||||||
|
config :tailwind,
|
||||||
|
version: "1.0.0",
|
||||||
|
default: []
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|> Igniter.Project.Config.configure(
|
||||||
|
"fake.exs",
|
||||||
|
:tailwind,
|
||||||
|
[:default, :args],
|
||||||
|
quote(
|
||||||
|
do:
|
||||||
|
~w(--config=tailwind.config.js --input=css/app.css --output=../output/assets/app.css)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|> Igniter.Project.Config.configure(
|
||||||
|
"fake.exs",
|
||||||
|
:tailwind,
|
||||||
|
[:default, :cd],
|
||||||
|
quote(do: Path.expand("../assets", __DIR__))
|
||||||
|
)
|
||||||
|
|
||||||
|
config_file = Rewrite.source!(rewrite, "config/fake.exs")
|
||||||
|
|
||||||
|
assert Source.get(config_file, :content) ==
|
||||||
|
"""
|
||||||
|
import Config
|
||||||
|
|
||||||
|
config :tailwind,
|
||||||
|
version: "1.0.0",
|
||||||
|
default: [
|
||||||
|
args: ~w(
|
||||||
|
--config=tailwind.config.js
|
||||||
|
--input=css/app.css
|
||||||
|
--output=../output/assets/app.css
|
||||||
|
),
|
||||||
|
cd: Path.expand("../assets", __DIR__)
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
end
|
||||||
|
|
||||||
test "present values can be updated by updating map keys" do
|
test "present values can be updated by updating map keys" do
|
||||||
%{rewrite: rewrite} =
|
%{rewrite: rewrite} =
|
||||||
Igniter.new()
|
Igniter.new()
|
||||||
|
|
Loading…
Reference in a new issue