MCPcopy Index your code
hub / github.com/cli/cli / TestResolveGitRoot

Function TestResolveGitRoot

internal/skills/installer/installer_test.go:488–518  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

486}
487
488func TestResolveGitRoot(t *testing.T) {
489 tests := []struct {
490 name string
491 client *git.Client
492 wantDir string
493 }{
494 {
495 name: "returns RepoDir when set",
496 client: &git.Client{RepoDir: "/monalisa/repo"},
497 wantDir: "/monalisa/repo",
498 },
499 {
500 name: "nil client falls back to cwd",
501 client: nil,
502 },
503 {
504 name: "empty RepoDir falls back to ToplevelDir or cwd",
505 client: &git.Client{},
506 },
507 }
508 for _, tt := range tests {
509 t.Run(tt.name, func(t *testing.T) {
510 got := ResolveGitRoot(tt.client)
511 if tt.wantDir != "" {
512 assert.Equal(t, tt.wantDir, got)
513 } else {
514 assert.NotEmpty(t, got, "should fall back to ToplevelDir or cwd")
515 }
516 })
517 }
518}

Callers

nothing calls this directly

Calls 3

ResolveGitRootFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected