-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add repr and str impl for OnFailureException (#68)
- Loading branch information
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import pytest | ||
|
||
from meiga import Error, Result | ||
from meiga.on_failure_exception import OnFailureException | ||
|
||
|
||
@pytest.mark.unit | ||
def test_should_str_as_expected_default_error(): | ||
result = Result(failure=Error()) | ||
|
||
exception = OnFailureException(result) | ||
|
||
assert "OnFailureException: Result[status: failure | value: Error]" == str( | ||
exception | ||
) | ||
|
||
|
||
@pytest.mark.unit | ||
def test_should_str_as_expected_an_exception(): | ||
wrapped_exception = ValueError("Something went wrong") | ||
result = Result(failure=wrapped_exception) | ||
|
||
exception = OnFailureException(result) | ||
|
||
assert ( | ||
f"OnFailureException: Result[status: failure | value: {wrapped_exception.__repr__()}]" | ||
== str(exception) | ||
) |