Skip to content

Commit

Permalink
test: add failing config tests (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibarakaiev authored Aug 13, 2024
1 parent ede41d3 commit ccdbfee
Showing 1 changed file with 106 additions and 0 deletions.
106 changes: 106 additions & 0 deletions test/igniter/project/config_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,43 @@ defmodule Igniter.Project.ConfigTest do
"""
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

Check failure on line 219 in test/igniter/project/config_test.exs

View workflow job for this annotation

GitHub Actions / ash-ci / mix test

test configure/6 it merges with 2 arg version of existing config with the config set to [] and the path is one level deeper than existing (Igniter.Project.ConfigTest)
%{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
%{rewrite: rewrite} =
Igniter.new()
Expand Down Expand Up @@ -313,6 +350,75 @@ defmodule Igniter.Project.ConfigTest do
"""
end

@tag :regression
test "arbitrary data structures can be used as values" do

Check failure on line 354 in test/igniter/project/config_test.exs

View workflow job for this annotation

GitHub Actions / ash-ci / mix test

test configure/6 arbitrary data structures can be used as values (Igniter.Project.ConfigTest)
%{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

Check failure on line 374 in test/igniter/project/config_test.exs

View workflow job for this annotation

GitHub Actions / ash-ci / mix test

test configure/6 quoted code can be used as values (Igniter.Project.ConfigTest)
%{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
%{rewrite: rewrite} =
Igniter.new()
Expand Down

0 comments on commit ccdbfee

Please sign in to comment.