Skip to content

Commit 4dbeab1

Browse files
authored
fix: modify_config_code twice with keyword values (#332)
* test: modify_config_code twice with keyword values
1 parent 928f586 commit 4dbeab1

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

lib/igniter/code/keyword.ex

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,8 @@ defmodule Igniter.Code.Keyword do
167167
{{:__block__, [], [key]}, {:__block__, [], [nil]}}
168168
end
169169

170-
[] ->
171-
{{:__block__, [format: :keyword], [key]}, {:__block__, [], [nil]}}
172-
173170
_current_node ->
174-
{{:__block__, [], [key]}, {:__block__, [], [nil]}}
171+
{{:__block__, [format: :keyword], [key]}, {:__block__, [], [nil]}}
175172
end
176173

177174
{:ok, zipper} =

test/igniter/project/config_test.exs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,25 @@ defmodule Igniter.Project.ConfigTest do
699699

700700
assert String.contains?(config, "config :fake, foo: [bar: true]")
701701
end
702+
703+
test "update existing config twice" do
704+
zipper =
705+
~s"""
706+
import Config
707+
"""
708+
|> Sourceror.parse_string!()
709+
|> Sourceror.Zipper.zip()
710+
711+
config =
712+
zipper
713+
|> Igniter.Project.Config.modify_config_code([:a], :app, 1)
714+
|> elem(1)
715+
|> Igniter.Project.Config.modify_config_code([:b], :app, 2)
716+
|> elem(1)
717+
|> Igniter.Util.Debug.code_at_node()
718+
719+
assert String.contains?(config, "config :app, a: 1, b: 2")
720+
end
702721
end
703722

704723
describe "configure_group" do

0 commit comments

Comments
 (0)