Conversation
…ests` to `TestHelper` to enable reuse across test classes
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #35 +/- ##
=========================================
+ Coverage 80.9% 81.0% +0.1%
- Complexity 132 136 +4
=========================================
Files 16 16
Lines 567 570 +3
Branches 64 66 +2
=========================================
+ Hits 459 462 +3
+ Misses 69 68 -1
- Partials 39 40 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| // Preface: This test looks a bit hacky because there's no API to | ||
| // directly manipulate, or prevent the auto-manipulation of, the index | ||
| // inside a watch. I've added some comments below to make it make sense. |
There was a problem hiding this comment.
This test was originally written before we added the filter mechanism to simulate overflows. Now that we have that, this test can be simplified a lot (without the hacks).
| private static class Bookkeeper implements Consumer<WatchEvent> { | ||
| private final List<WatchEvent> events = Collections.synchronizedList(new ArrayList<>()); | ||
|
|
||
| public Stream<WatchEvent> events(WatchEvent.Kind... kinds) { | ||
| var list = Arrays.asList(kinds.length == 0 ? WatchEvent.Kind.values() : kinds); | ||
| return events.stream().filter(e -> list.contains(e.getKind())); | ||
| } | ||
|
|
||
| public Stream<Path> fullPaths(WatchEvent.Kind... kinds) { | ||
| return events(kinds).map(WatchEvent::calculateFullPath); | ||
| } | ||
|
|
||
| @Override | ||
| public void accept(WatchEvent e) { | ||
| events.add(e); | ||
| } | ||
| } |
There was a problem hiding this comment.
This class was moved to TestHelper, so it can be reused across test classes. (Actually, after moving it, the class was rewritten quite a bit, but the idea remained the same.)
125ed84 to
9af3180
Compare
9af3180 to
21e1592
Compare
DavyLandman
left a comment
There was a problem hiding this comment.
Just a few small things, looks good.
In #20, a number of tests were added for overflow handling. The bookkeeping code to keep track of actual events vs. expected events in those tests had two issues: (a) two tests still used counting of events, which can be unreliable; (b) a few other tests had roughly the same bookkeeping code duplicated.
This PR fixes these issues by adding a general
Bookkeepingclass that is: (a) not based on counting; (b) reused across tests.