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

Function TestClientPathFromRootReturnsNestedPath

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

Source from the content-addressed store, hash-verified

1120}
1121
1122func TestClientPathFromRootReturnsNestedPath(t *testing.T) {
1123 // Given a client operating from a nested repository directory
1124 repo := newTestRepo(t)
1125 nestedDir := filepath.Join(repo.dir, "some", "path")
1126 require.NoError(t, os.MkdirAll(nestedDir, 0700))
1127 client := Client{RepoDir: nestedDir}
1128
1129 // When its path relative to the repository root is requested
1130 dir := client.PathFromRoot(t.Context())
1131
1132 // Then the nested path is returned without a trailing separator
1133 assert.Equal(t, "some/path", filepath.ToSlash(dir))
1134}
1135
1136func TestClientPathFromRootReturnsEmptyOutsideRepository(t *testing.T) {
1137 // Given a client outside a Git repository

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected