-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TwinagleException includes error code in message (#388)
the Specs2 `throwsA` matcher only takes into account the exception class and message, leading to false-positive tests that expected equality/pattern-matching semantics (on the error code specifically). Update the exception message to include the error code as well. Co-authored-by: Christopher Taylor <[email protected]>
- Loading branch information
1 parent
240ee26
commit 32e82ce
Showing
2 changed files
with
25 additions
and
1 deletion.
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
20 changes: 20 additions & 0 deletions
20
runtime/src/test/scala/com/soundcloud/twinagle/TwinagleExceptionSpec.scala
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,20 @@ | ||
package com.soundcloud.twinagle | ||
|
||
import org.specs2.matcher.ResultMatchers.beFailing | ||
import org.specs2.mutable.Specification | ||
|
||
class TwinagleExceptionSpec extends Specification { | ||
|
||
"TwinagleException when seen as a RuntimeException, message should contain the error code" in { | ||
val twinagleException = TwinagleException(ErrorCode.Internal, "something went wrong") | ||
twinagleException.getMessage ==== "something went wrong [internal]" | ||
} | ||
|
||
"specs2 throwsA(someTwinagleException) fails if someTwinagleException has different error code" in { | ||
val internalTwinagleException = TwinagleException(ErrorCode.Internal, "my error message") | ||
val expectedException = TwinagleException(ErrorCode.NotFound, "my error message") | ||
def myFunction(): Unit = throw internalTwinagleException | ||
(myFunction() must throwA(expectedException)) must beFailing | ||
} | ||
|
||
} |