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: Copy fails with umbrella mix test stale (make Mimic.copy idempotent) #47

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
CI test
dylan-chong committed Jul 27, 2022
commit f9e17cd1ddf0a404b644da586753beb4f45e4a72
26 changes: 14 additions & 12 deletions test/mimic_test.exs
Original file line number Diff line number Diff line change
@@ -911,22 +911,24 @@ defmodule Mimic.Test do
describe "copy/1 with duplicates does nothing" do
setup :set_mimic_private

test "stubs still stub" do
parent_pid = self()
for i <- 1..10_000 do
test "stubs still stub #{i}" do
parent_pid = self()

Mimic.copy(Calculator)
Mimic.copy(Calculator)
Mimic.copy(Calculator)
Mimic.copy(Calculator)

Calculator
|> stub(:add, fn x, y ->
send(parent_pid, {:add, x, y})
:stubbed
end)
Calculator
|> stub(:add, fn x, y ->
send(parent_pid, {:add, x, y})
:stubbed
end)

Mimic.copy(Calculator)
Mimic.copy(Calculator)

assert Calculator.add(1, 2) == :stubbed
assert_receive {:add, 1, 2}
assert Calculator.add(1, 2) == :stubbed
assert_receive {:add, 1, 2}
end
end
end
end