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

Function TestRemoveClientRemovesHash

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

Source from the content-addressed store, hash-verified

379}
380
381func TestRemoveClientRemovesHash(t *testing.T) {
382 tmpDir := t.TempDir()
383 authFile := filepath.Join(tmpDir, "sample.json")
384 var reloads int32
385
386 w := &Watcher{
387 authDir: tmpDir,
388 lastAuthHashes: make(map[string]string),
389 reloadCallback: func(*config.Config) {
390 atomic.AddInt32(&reloads, 1)
391 },
392 }
393 w.SetConfig(&config.Config{AuthDir: tmpDir})
394 // Use normalizeAuthPath to set up the hash with the correct key format
395 w.lastAuthHashes[w.normalizeAuthPath(authFile)] = "hash"
396
397 w.removeClient(authFile)
398 if _, ok := w.lastAuthHashes[w.normalizeAuthPath(authFile)]; ok {
399 t.Fatal("expected hash to be removed after deletion")
400 }
401 if got := atomic.LoadInt32(&reloads); got != 0 {
402 t.Fatalf("expected no reload callback for auth removal, got %d", got)
403 }
404}
405
406func TestAuthFileClientChangesNotifyUsageSubscribersToRefresh(t *testing.T) {
407 tmpDir := t.TempDir()

Callers

nothing calls this directly

Calls 3

SetConfigMethod · 0.95
normalizeAuthPathMethod · 0.95
removeClientMethod · 0.95

Tested by

no test coverage detected