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

Function TestClientPathFromRoot

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

Source from the content-addressed store, hash-verified

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