`Igniter.Test.assert_has_issue/3` errors due to undefined variable `found_issue`
Describe the bug Igniter has been quite useful to streamline some of our repetitive tasks. Thank you!
After updating to a version > v0.5.51, tests that call Igniter.Test.assert_has_issue/3 fail with the error undefined variable "found_issue" (context Igniter.Test). That variable exists only in Igniter.Test and nowhere in the project making use of Igniter.
I may have a fix and am happy to create a PR if I'm heading in the right direction.
To Reproduce
Add a call to Igniter.add_issue/2 to an Igniter task you've created, for example:
Igniter.add_issue(igniter, "At least one of --schema or --context is required.")
Then in a test that covers this task, add a call to Igniter.Test.assert_has_issue/3, for example:
phx_test_project()
|> Igniter.compose_task("foundry.gen.some_task", [])
|> assert_has_issue(&(&1 =~ "At least one of --schema or --context is required."))
Run the test and observe an error like this one:
error: undefined variable "found_issue" (context Igniter.Test)
│
11 │ |> assert_has_issue(&(&1 =~ "At least one of --schema or --context is required."))
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
│
Expected behavior I expect the test to pass or fail based on the task's behavior, and not throw an error about an undefined variable.
Runtime
- Elixir version: 1.18.3
- Erlang version: 27
- OS: MacOS 15.5
- Ash version: n/a
- any related package versions: n/a
Additional context This appears to be related to this commit.
Modifying how condition is set in the beginning of the body of Igniter.Test.assert_has_issue/3 to follow the same pattern as in Igniter.Test.assert_has_warning/2 and Igniter.Test.assert_has_notice/2 seems to resolve the issue:
@@ -342,10 +342,10 @@ defmodule Igniter.Test do
defmacro assert_has_issue(igniter, path \\ nil, issue) do
quote bind_quoted: [igniter: igniter, path: path, issue: issue] do
condition =
- if is_binary(issue) do
- issue == found_issue
+ if is_function(issue, 1) do
+ issue
else
- issue.(found_issue)
+ &(&1 == issue)
end
if path do
Rolling back to v0.5.51 of Igniter also resolves it.
PR welcome 🙇