-
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.
Added success_handler and failure_handler when unwrap values with Res…
…ult handle function. Improved Error string representation
- Loading branch information
1 parent
919b3ab
commit 39d606f
Showing
7 changed files
with
125 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,3 +79,4 @@ target/ | |
|
||
*.idea | ||
.pytest_cache | ||
upload_to_pypi.sh |
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
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
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,27 @@ | ||
import pytest | ||
|
||
from meiga import Result, Error | ||
|
||
|
||
@pytest.mark.unit | ||
def test_should_repr_as_expected_default_error(): | ||
|
||
result = Result(failure=Error()) | ||
|
||
assert "Result[status: failure | value: Error]" == result.__repr__() | ||
|
||
|
||
@pytest.mark.unit | ||
def test_should_repr_as_expected_an_error_with_message(): | ||
given_any_message = "any message" | ||
|
||
class ErrorWithMessage(Error): | ||
def __init__(self, message: str): | ||
self.message = message | ||
|
||
result = Result(failure=ErrorWithMessage(given_any_message)) | ||
|
||
assert ( | ||
f"Result[status: failure | value: ErrorWithMessage: {given_any_message}]" | ||
== result.__repr__() | ||
) |
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