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

Function runCloneCommandWithConfig

pkg/cmd/repo/clone/clone_test.go:118–154  ·  view source on GitHub ↗
(httpClient *http.Client, cfg gh.Config, cli string)

Source from the content-addressed store, hash-verified

116}
117
118func runCloneCommandWithConfig(httpClient *http.Client, cfg gh.Config, cli string) (*test.CmdOut, error) {
119 ios, stdin, stdout, stderr := iostreams.Test()
120 fac := &cmdutil.Factory{
121 IOStreams: ios,
122 HttpClient: func() (*http.Client, error) {
123 return httpClient, nil
124 },
125 Config: func() (gh.Config, error) {
126 return cfg, nil
127 },
128 GitClient: &git.Client{
129 GhPath: "some/path/gh",
130 GitPath: "some/path/git",
131 },
132 }
133
134 cmd := NewCmdClone(fac, nil)
135
136 argv, err := shlex.Split(cli)
137 cmd.SetArgs(argv)
138
139 cmd.SetIn(stdin)
140 cmd.SetOut(stderr)
141 cmd.SetErr(stderr)
142
143 if err != nil {
144 panic(err)
145 }
146
147 _, err = cmd.ExecuteC()
148
149 if err != nil {
150 return nil, err
151 }
152
153 return &test.CmdOut{OutBuf: stdout, ErrBuf: stderr}, nil
154}
155
156func Test_RepoClone(t *testing.T) {
157 tests := []struct {

Calls 2

TestFunction · 0.92
NewCmdCloneFunction · 0.70

Tested by

no test coverage detected