Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This rewrites quite a lot of tests to be much more easily readable. While working on #472 I wanted to check "how do renames behave now?", and found this quite hard as most test cases were >90% "plumbing", and seeing "what file operations does this do?" and "what events do we get?" was not very easy. So refactor the lot, based on some work I did in #472: - Add a bunch of "shell-like" helper functions so you're not forever typing error checks, filepath.Join(), and eventSeparator(). Just touch(t, tmp, "file") will create a file in tmp. - Add eventCollector type which will collect all events in in a slice, replacing the previous "counter". This also ensures that the Watcher is closed within a second (this removes a lot of duplicate code). This is also much more precise than merely counting events; before random events could get emitted but if you weren't counting those then you'd never know. Downside is that some tests are a bit more flaky now as some behaviours are not always consistent in various edge cases; these are pre-existing bugs. - Add Events (plural) type (only for tests), and helper function to create this from a string like: REMOVE /link CREATE /link WRITE /link Which makes seeing which events are received, diffing them, etc. much easier. - Add Parallel() for most tests; reduces runtime on my system from ~12 seconds to ~6 seconds. All in all it reduces the integrations_test.go from 1279 lines to 405 lines and it's quite easy to see which events are expected for which operations, which should make things a lot easier going forward.
- Loading branch information