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

Function TestClientPathFromRoot

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

Source from the content-addressed store, hash-verified

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