Skip to content

Commit 4e97bea

Browse files
Stefan Satorisidore
authored andcommitted
- F better help message for DateScrubber
1 parent 7304b39 commit 4e97bea

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

approvaltests-tests/src/test/java/org/approvaltests/scrubbers/DateScrubberTest.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,4 +252,11 @@ void testForSimpleDateFormat()
252252
String result = "created at " + sdf.format(new Date());
253253
Approvals.verify(result, new Options().inline(expected).withScrubber(scrubber));
254254
}
255-
}
255+
256+
@Test
257+
@UseReporter(AutoApproveReporter.class)
258+
void testDateFormatNotFoundMessage()
259+
{
260+
Approvals.verifyException(() -> DateScrubber.getScrubberFor("this format does not exist"));
261+
}
262+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
com.spun.util.FormattedException: No match found for this format does not exist.
2+
Feel free to add your date at https://github.com/approvals/ApprovalTests.Java/issues/112
3+
Current supported formats are:
4+
[a-zA-Z]{3} [a-zA-Z]{3} \d{2} \d{2}:\d{2}:\d{2}
5+
[a-zA-Z]{3} [a-zA-Z]{3} \d{2} \d{2}:\d{2}:\d{2} [a-zA-Z]{3,4} \d{4}
6+
(Mon|Tue|Wed|Thu|Fri|Sat|Sun), \d{2} (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} GMT
7+
[a-zA-Z]{3} [a-zA-Z]{3} \d{2} \d{4} \d{2}:\d{2}:\d{2}.\d{3}
8+
[a-zA-Z]{3} [a-zA-Z]{3} \d{2} \d{2}:\d{2}:\d{2} -\d{4} \d{4}
9+
\d{2} [a-zA-Z]{3} \d{4} \d{2}:\d{2}:\d{2},\d{3}
10+
[A-Za-z]{3} \d{2} \d{2}:\d{2}
11+
[a-zA-Z]{3} \d{2}, \d{4} \d{2}:\d{2}:\d{2} [a-zA-Z]{2} [a-zA-Z]{3}
12+
\d{2}:\d{2}:\d{2}
13+
\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2}(\.\d{3})?
14+
\d{4}-\d{1,2}-\d{1,2}T\d{1,2}:\d{2}Z
15+
\d{4}-\d{1,2}-\d{1,2}T\d{1,2}:\d{2}:\d{2}Z
16+
\d{4}-\d{1,2}-\d{1,2}T\d{1,2}:\d{2}\:\d{2}\.\d{3}Z
17+
\d{8}T\d{6}Z
18+
\d{4}-\d{2}-\d{2}
19+
\d{4}-\d{1,2}-\d{1,2}T\d{1,2}:\d{2}:\d{2}(\.\d{1,9})?Z
20+
\d{4}-\d{1,2}-\d{1,2}T\d{1,2}:\d{2}:\d{2}(\.\d{1,9})?[+-]\d{2}:\d{2}
21+
\d{4}-\d{1,2}-\d{1,2}T\d{1,2}:\d{2}:\d{2}(\.\d{1,9})?
22+
\d{2}[-/.]\d{2}[-/.]\d{4}\s\d{2}:\d{2}(:\d{2})?( (?:pm|am|PM|AM))?
23+
\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+

approvaltests/src/main/java/org/approvaltests/scrubbers/DateScrubber.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ public static DateScrubber getScrubberFor(String formattedExample)
9393
{ return scrubber; }
9494
}
9595
throw new FormattedException(
96-
"No match found for %s.\n Feel free to add your date at https://github.com/approvals/ApprovalTests.Java/issues/112 \n Current supported formats are: %s",
97-
formattedExample, Query.select(getSupportedFormats(), SupportedFormat::getRegex));
96+
"No match found for %s.\nFeel free to add your date at https://github.com/approvals/ApprovalTests.Java/issues/112 \nCurrent supported formats are: \n\t%s",
97+
formattedExample, Query.select(getSupportedFormats(), SupportedFormat::getRegex).join("\n\t"));
9898
}
9999

100100
public static DateScrubber getNull()

0 commit comments

Comments
 (0)