MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / TestShouldDebounceRemove

Function TestShouldDebounceRemove

internal/watcher/watcher_test.go:576–594  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

574}
575
576func TestShouldDebounceRemove(t *testing.T) {
577 w := &Watcher{}
578 path := filepath.Clean("test.json")
579
580 if w.shouldDebounceRemove(path, time.Now()) {
581 t.Fatal("first call should not debounce")
582 }
583 if !w.shouldDebounceRemove(path, time.Now()) {
584 t.Fatal("second call within window should debounce")
585 }
586
587 w.clientsMutex.Lock()
588 w.lastRemoveTimes = map[string]time.Time{path: time.Now().Add(-2 * authRemoveDebounceWindow)}
589 w.clientsMutex.Unlock()
590
591 if w.shouldDebounceRemove(path, time.Now()) {
592 t.Fatal("call after window should not debounce")
593 }
594}
595
596func TestAuthFileUnchangedUsesHash(t *testing.T) {
597 tmpDir := t.TempDir()

Callers

nothing calls this directly

Calls 1

shouldDebounceRemoveMethod · 0.95

Tested by

no test coverage detected