Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Test.expect in shared mode #465

Merged

Conversation

hkrutzer
Copy link
Contributor

@hkrutzer hkrutzer commented Mar 9, 2025

This commit fixes

Req.Test.set_req_test_to_shared()

Req.Test.expect(MyApp.Weather, fn conn ->
  Req.Test.json(conn, %{"celsius" => 25555.0})
end)

assert {:ok, %Req.Response{}} == Reqrepro.hello()

which would produce

     ** (CaseClauseError) no case clause matching: %{expectations: [#Function<0.11329399/1 in ReqreproTest."test test"/1>]}
     code: assert {:ok, %Req.Response{}} == Reqrepro.hello()
     stacktrace:
       (req 0.5.8) lib/req/test.ex:390: Req.Test.__fetch_plug__/1
       (req 0.5.8) lib/req/test.ex:632: Req.Test.call/2
       (req 0.5.8) lib/req/steps.ex:964: Req.Steps.run_plug/1
       (req 0.5.8) lib/req/request.ex:1106: Req.Request.run_request/1
       (req 0.5.8) lib/req/request.ex:1050: Req.Request.run/1

This commit fixes
```
Req.Test.set_req_test_to_shared()

Req.Test.expect(MyApp.Weather, fn conn ->
  Req.Test.json(conn, %{"celsius" => 25555.0})
end)

assert {:ok, %Req.Response{}} == Reqrepro.hello()
```

which would produce
```
** (CaseClauseError) no case clause matching: %{expectations: [#Function<0.11329399/1 in ReqreproTest."test test"/1>]}
```
@wojtekmach wojtekmach merged commit 6da1bd2 into wojtekmach:main Mar 10, 2025
2 checks passed
@wojtekmach
Copy link
Owner

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants