-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: add
foldCause
to HttpError (#1066)
- Loading branch information
1 parent
e0e413b
commit 2aed79e
Showing
2 changed files
with
33 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,21 @@ | ||
package zhttp.http | ||
|
||
import zio.test.Assertion.equalTo | ||
import zio.test.{DefaultRunnableSpec, assert} | ||
|
||
object HttpErrorSpec extends DefaultRunnableSpec { | ||
def spec = suite("HttpError") { | ||
suite("foldCause") { | ||
test("should fold the cause") { | ||
val error = HttpError.InternalServerError(cause = Option(new Error("Internal server error"))) | ||
val result = error.foldCause("")(cause => cause.getMessage) | ||
assert(result)(equalTo("Internal server error")) | ||
} + | ||
test("should fold with no cause") { | ||
val error = HttpError.NotFound(!!) | ||
val result = error.foldCause("Page not found")(cause => cause.getMessage) | ||
assert(result)(equalTo("Page not found")) | ||
} | ||
} | ||
} | ||
} |