(t *testing.T)
| 379 | } |
| 380 | |
| 381 | func 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 | |
| 406 | func TestAuthFileClientChangesNotifyUsageSubscribersToRefresh(t *testing.T) { |
| 407 | tmpDir := t.TempDir() |
nothing calls this directly
no test coverage detected