Last active
September 26, 2021 23:57
-
-
Save zorn/02e4e44d726fdd9b42f10fb10bd02407 to your computer and use it in GitHub Desktop.
How we use `Kernal.match/2` to validate that a list has an expected value.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# chunk of code from our tests where we validated that an expected metric was captured | |
# heavily edited out company info | |
metrics = | |
capture_metrics(fn -> | |
with_trace(fn -> | |
assert {:ok, _result} = Work.stuff() | |
end) | |
end) | |
assert Enum.any?( | |
metrics, | |
&match?( | |
%{ | |
metadata: %{ | |
result_id: ^result_id, | |
status: :success | |
}, | |
topic: "engine.work.reconcile" | |
}, | |
&1 | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment