MCPcopy Create free account
hub / github.com/cli/cli / TestClientToplevelDirReturnsRepositoryRootFromSubdirectory

Function TestClientToplevelDirReturnsRepositoryRootFromSubdirectory

git/client_test.go:1063–1076  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1061}
1062
1063func TestClientToplevelDirReturnsRepositoryRootFromSubdirectory(t *testing.T) {
1064 // Given a client operating from a nested repository directory
1065 repo := newTestRepo(t)
1066 nestedDir := filepath.Join(repo.dir, "some", "path")
1067 require.NoError(t, os.MkdirAll(nestedDir, 0700))
1068 client := Client{RepoDir: nestedDir}
1069
1070 // When the top-level directory is requested
1071 dir, err := client.ToplevelDir(t.Context())
1072
1073 // Then the repository root is returned
1074 require.NoError(t, err)
1075 assert.Equal(t, filepath.ToSlash(repo.dir), filepath.ToSlash(dir))
1076}
1077
1078func TestClientToplevelDirReportsNonRepository(t *testing.T) {
1079 // Given a client outside a Git repository

Callers

nothing calls this directly

Calls 5

ToplevelDirMethod · 0.95
newTestRepoFunction · 0.85
JoinMethod · 0.80
MkdirAllMethod · 0.80
EqualMethod · 0.80

Tested by

no test coverage detected