Skip to content

Igniter.Project.Config.configure/6 should do nothing when updater returns :error #314

@SteffenDE

Description

@SteffenDE

Versions

Elixir 1.18.4
Erlang/OTP 28.0.1

Operating system

macOS

Current Behavior

When the updater returns :error, a new config entry is added:

Update: config/config.exs

1 1   |import Config
2 2   |
3   - |config :my_app, foo: [
4   - |  bar: :baz
5   - |]
  3 + |config :my_app, foo: nil
6 4   |
  5 + |config :my_app,
  6 + |  foo: [
  7 + |    bar: :baz
  8 + |  ]
  9 + 

Reproduction

igniter =
  Igniter.Test.test_project(
    files: %{
      "config/config.exs" => """
      import Config

      config :my_app, foo: [
        bar: :baz
      ]
      """
    }
  )

if Igniter.Project.Config.configures_key?(igniter, "config.exs", :my_app, :foo) do
  Igniter.Project.Config.configure(igniter, "config.exs", :my_app, :foo, nil,
    updater: fn _zipper -> :error end
  )
else
  igniter
end
|> Igniter.Test.diff()
|> IO.puts()

Expected Behavior

The config should stay as is, since the updater failed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions