MCPcopy
hub / github.com/cli/cli / TestClientCommand

Function TestClientCommand

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

Source from the content-addressed store, hash-verified

20)
21
22func TestClientCommand(t *testing.T) {
23 tests := []struct {
24 name string
25 repoDir string
26 gitPath string
27 wantExe string
28 wantArgs []string
29 }{
30 {
31 name: "creates command",
32 gitPath: "path/to/git",
33 wantExe: "path/to/git",
34 wantArgs: []string{"path/to/git", "ref-log"},
35 },
36 {
37 name: "adds repo directory configuration",
38 repoDir: "path/to/repo",
39 gitPath: "path/to/git",
40 wantExe: "path/to/git",
41 wantArgs: []string{"path/to/git", "-C", "path/to/repo", "ref-log"},
42 },
43 }
44 for _, tt := range tests {
45 t.Run(tt.name, func(t *testing.T) {
46 in, out, errOut := &bytes.Buffer{}, &bytes.Buffer{}, &bytes.Buffer{}
47 client := Client{
48 Stdin: in,
49 Stdout: out,
50 Stderr: errOut,
51 RepoDir: tt.repoDir,
52 GitPath: tt.gitPath,
53 }
54 cmd, err := client.Command(context.Background(), "ref-log")
55 assert.NoError(t, err)
56 assert.Equal(t, tt.wantExe, cmd.Path)
57 assert.Equal(t, tt.wantArgs, cmd.Args)
58 assert.Equal(t, in, cmd.Stdin)
59 assert.Equal(t, out, cmd.Stdout)
60 assert.Equal(t, errOut, cmd.Stderr)
61 })
62 }
63}
64
65func TestClientAuthenticatedCommand(t *testing.T) {
66 tests := []struct {

Callers

nothing calls this directly

Calls 3

CommandMethod · 0.95
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected