MCPcopy Index your code
hub / github.com/coder/coder / TestScanRateLimiting

Function TestScanRateLimiting

agent/agentgit/agentgit_test.go:389–411  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

387}
388
389func TestScanRateLimiting(t *testing.T) {
390 t.Parallel()
391
392 repoDir := initTestRepo(t)
393 logger := slogtest.Make(t, nil)
394
395 h := agentgit.NewHandler(logger)
396
397 h.Subscribe([]string{filepath.Join(repoDir, "file.go")})
398
399 // First scan should succeed.
400 ctx := context.Background()
401 msg1 := h.Scan(ctx)
402 // Even if no dirty files, the first scan always runs.
403 // The important thing is it doesn't panic.
404 _ = msg1
405
406 // Create a dirty file so the next scan has something to report.
407 require.NoError(t, os.WriteFile(filepath.Join(repoDir, "new.go"), []byte("package x\n"), 0o600))
408
409 msg2 := h.Scan(ctx)
410 require.NotNil(t, msg2, "scan with new dirty file should return changes")
411}
412
413func TestSubscribeDeeplyNestedFile(t *testing.T) {
414 t.Parallel()

Callers

nothing calls this directly

Calls 5

SubscribeMethod · 0.95
ScanMethod · 0.95
NewHandlerFunction · 0.92
initTestRepoFunction · 0.85
WriteFileMethod · 0.65

Tested by

no test coverage detected