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

Function TestSubscribeDeeplyNestedFile

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

Source from the content-addressed store, hash-verified

411}
412
413func TestSubscribeDeeplyNestedFile(t *testing.T) {
414 t.Parallel()
415
416 repoDir := initTestRepo(t)
417 logger := slogtest.Make(t, nil)
418
419 // Create a deeply nested directory structure inside the repo.
420 nestedDir := filepath.Join(repoDir, "a", "b", "c")
421 require.NoError(t, os.MkdirAll(nestedDir, 0o700))
422 nestedFile := filepath.Join(nestedDir, "deep.go")
423 require.NoError(t, os.WriteFile(nestedFile, []byte("package deep\n"), 0o600))
424
425 h := agentgit.NewHandler(logger)
426
427 added := h.Subscribe([]string{nestedFile})
428 require.True(t, added, "deeply nested file should resolve to repo root")
429
430 msg := h.Scan(context.Background())
431 require.NotNil(t, msg)
432 require.Len(t, msg.Repositories, 1)
433 require.Equal(t, repoDir, msg.Repositories[0].RepoRoot)
434
435 // The nested file should appear in the unified diff.
436 require.Contains(t, msg.Repositories[0].UnifiedDiff, "a/b/c/deep.go")
437}
438
439func TestSubscribeNestedGitRepos(t *testing.T) {
440 t.Parallel()

Callers

nothing calls this directly

Calls 9

SubscribeMethod · 0.95
ScanMethod · 0.95
NewHandlerFunction · 0.92
initTestRepoFunction · 0.85
MkdirAllMethod · 0.80
WriteFileMethod · 0.65
LenMethod · 0.45
EqualMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected