@@ -47,14 +47,15 @@ enum class Mode {
47
47
msg(" Snapshot " + SnapshotNotEqualErrorMsg .forUnequalStrings(expected, actual))
48
48
internal fun msgSnapshotMismatchBinary (expected : ByteArray , actual : ByteArray ) =
49
49
msgSnapshotMismatch(expected.toQuotedPrintable(), actual.toQuotedPrintable())
50
- internal fun msgVcrSnapshotNotFound () = msg(" VCR snapshot not found" )
51
- internal fun msgVcrMismatch (key : String , expected : String , actual : String ) =
52
- msg(" VCR frame $key " + SnapshotNotEqualErrorMsg .forUnequalStrings(expected, actual))
53
- internal fun msgVcrUnread (expected : Int , actual : Int ) =
54
- msg(" VCR frames unread - only $actual were read out of $expected " )
55
- internal fun msgVcrUnderflow (expected : Int ) =
56
- msg(
57
- " VCR frames exhausted - only $expected are available but you tried to read ${expected + 1 } " )
50
+ internal fun msgVcrSnapshotNotFound (call : CallStack ) = msgVcr(" VCR snapshot not found" , call)
51
+ internal fun msgVcrMismatch (key : String , expected : String , actual : String , call : CallStack ) =
52
+ msgVcr(" VCR frame $key " + SnapshotNotEqualErrorMsg .forUnequalStrings(expected, actual), call)
53
+ internal fun msgVcrUnread (expected : Int , actual : Int , call : CallStack ) =
54
+ msgVcr(" VCR frames unread - only $actual were read out of $expected " , call)
55
+ internal fun msgVcrUnderflow (expected : Int , call : CallStack ) =
56
+ msgVcr(
57
+ " VCR frames exhausted - only $expected are available but you tried to read ${expected + 1 } " ,
58
+ call)
58
59
private fun ByteArray.toQuotedPrintable (): String {
59
60
val sb = StringBuilder ()
60
61
for (byte in this ) {
@@ -71,12 +72,18 @@ enum class Mode {
71
72
when (this ) {
72
73
interactive ->
73
74
" $headline \n " +
74
- (if (headline.startsWith(" Snapshot " ))
75
- " ‣ update this snapshot by adding `_TODO` to the function name\n " +
76
- " ‣ update all snapshots in this file by adding `//selfieonce` or `//SELFIEWRITE`"
77
- else
78
- " ‣ update all snapshots in this file by adding `//selfieonce` or `//SELFIEWRITE`\n " +
79
- " ‣ if that doesn't work remember to put your test rule into the `selfie` package" )
75
+ " ‣ update this snapshot by adding `_TODO` to the function name\n " +
76
+ " ‣ update all snapshots in this file by adding `//selfieonce` or `//SELFIEWRITE`"
77
+ readonly -> headline
78
+ overwrite -> " $headline \n (didn't expect this to ever happen in overwrite mode)"
79
+ }
80
+ private fun msgVcr (headline : String , call : CallStack ) =
81
+ when (this ) {
82
+ interactive ->
83
+ " $headline \n " +
84
+ " ‣ update all snapshots in this file by adding `//selfieonce` or `//SELFIEWRITE`\n " +
85
+ " ‣ could not find control comment in ${call.location.ideLink(Selfie .system.layout)} \n " +
86
+ " ‣ remember to call `Selfie.vcrTestLocator()` in the test itself, or put the file above into the `selfie` package to mark that it is not the test file"
80
87
readonly -> headline
81
88
overwrite -> " $headline \n (didn't expect this to ever happen in overwrite mode)"
82
89
}
0 commit comments