File tree Expand file tree Collapse file tree 2 files changed +26
-4
lines changed
Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -231,7 +231,13 @@ defmodule Tesla.Mock do
231231 defp pdict_get do
232232 pid_holder =
233233 Enum . find ( Process . get ( :"$ancestors" , [ ] ) , self ( ) , fn ancestor ->
234- ! is_nil ( Process . get ( ancestor , __MODULE__ ) )
234+ is_holder? =
235+ ancestor
236+ |> Process . info ( )
237+ |> Keyword . get ( :dictionary )
238+ |> Keyword . get ( __MODULE__ )
239+
240+ ! is_nil ( is_holder? )
235241 end )
236242 |> case do
237243 nil -> raise "Unknown pid_holder in mock"
Original file line number Diff line number Diff line change @@ -85,15 +85,31 @@ defmodule Tesla.MockTest do
8585 assert env . body == % { "id" => 42 }
8686 end
8787
88- test "mock a request inside a spawned process" do
89- task =
88+ test "mock a request inside a child process" do
89+ child_task =
9090 Task . async ( fn ->
9191 assert { :ok , % Tesla.Env { } = env } = Client . get ( "/json" )
9292 assert env . status == 200
9393 assert env . body == % { "json" => 123 }
9494 end )
9595
96- Task . await ( task )
96+ Task . await ( child_task )
97+ end
98+
99+ test "mock a request inside a grandchild process" do
100+ grandchild_task =
101+ Task . async ( fn ->
102+ child_task =
103+ Task . async ( fn ->
104+ assert { :ok , % Tesla.Env { } = env } = Client . get ( "/json" )
105+ assert env . status == 200
106+ assert env . body == % { "json" => 123 }
107+ end )
108+
109+ Task . await ( child_task )
110+ end )
111+
112+ Task . await ( grandchild_task )
97113 end
98114 end
99115
You can’t perform that action at this time.
0 commit comments