search: deflake TestDirWatcherUnloadOnce (#1015)
TestDirWatcherUnloadOnce occasionally failed in CI with a queued
"spurious load" event after Stop().
This is expected under fsnotify: a single logical write can emit multiple
filesystem events, and DirectoryWatcher can therefore enqueue extra load
notifications before shutdown completes. The old assertion treated any
leftover load event as a bug, which made the test timing-sensitive.
Update the test to drain queued load notifications after Stop() and keep
asserting that no extra drop event is emitted. That preserves the behavior
we care about (delete triggers unload, and unload is not repeated) while
removing a brittle assumption about load event multiplicity.
Reproduced flake before with:
go test ./search -run TestDirWatcherUnloadOnce -count=500
Validated after change with:
go test ./search -run TestDirWatcherUnloadOnce -count=500
Amp-Thread-ID: https://ampcode.com/threads/T-019d0104-367c-719f-a5f0-e7a95136407c
Co-authored-by: Amp <amp@ampcode.com>