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

Function TestClientPathFromRoot

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

Source from the content-addressed store, hash-verified

1513}
1514
1515func TestClientPathFromRoot(t *testing.T) {
1516 tests := []struct {
1517 name string
1518 cmdExitStatus int
1519 cmdStdout string
1520 cmdStderr string
1521 wantCmdArgs string
1522 wantErrorMsg string
1523 wantDir string
1524 }{
1525 {
1526 name: "current path from root",
1527 cmdStdout: "some/path/",
1528 wantCmdArgs: `path/to/git rev-parse --show-prefix`,
1529 wantDir: "some/path",
1530 },
1531 {
1532 name: "git error",
1533 cmdExitStatus: 1,
1534 cmdStderr: "git error message",
1535 wantCmdArgs: `path/to/git rev-parse --show-prefix`,
1536 wantDir: "",
1537 },
1538 }
1539 for _, tt := range tests {
1540 t.Run(tt.name, func(t *testing.T) {
1541 cmd, cmdCtx := createCommandContext(t, tt.cmdExitStatus, tt.cmdStdout, tt.cmdStderr)
1542 client := Client{
1543 GitPath: "path/to/git",
1544 commandContext: cmdCtx,
1545 }
1546 dir := client.PathFromRoot(context.Background())
1547 assert.Equal(t, tt.wantCmdArgs, strings.Join(cmd.Args[3:], " "))
1548 assert.Equal(t, tt.wantDir, dir)
1549 })
1550 }
1551}
1552
1553func TestClientUnsetRemoteResolution(t *testing.T) {
1554 tests := []struct {

Callers

nothing calls this directly

Calls 5

PathFromRootMethod · 0.95
createCommandContextFunction · 0.85
EqualMethod · 0.80
JoinMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected