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

Function Test_RepoClone

pkg/cmd/repo/clone/clone_test.go:156–277  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

154}
155
156func Test_RepoClone(t *testing.T) {
157 tests := []struct {
158 name string
159 args string
160 sshURL string
161 gitProtocol string
162 want string
163 }{
164 {
165 name: "shorthand",
166 args: "OWNER/REPO",
167 want: "git clone https://github.com/OWNER/REPO.git",
168 },
169 {
170 name: "shorthand with directory",
171 args: "OWNER/REPO target_directory",
172 want: "git clone https://github.com/OWNER/REPO.git target_directory",
173 },
174 {
175 name: "clone arguments",
176 args: "OWNER/REPO -- -o upstream --depth 1",
177 want: "git clone -o upstream --depth 1 https://github.com/OWNER/REPO.git",
178 },
179 {
180 name: "clone arguments with directory",
181 args: "OWNER/REPO target_directory -- -o upstream --depth 1",
182 want: "git clone -o upstream --depth 1 https://github.com/OWNER/REPO.git target_directory",
183 },
184 {
185 name: "HTTPS URL",
186 args: "https://github.com/OWNER/REPO",
187 want: "git clone https://github.com/OWNER/REPO.git",
188 },
189 {
190 name: "HTTPS URL with extra path parts",
191 args: "https://github.com/OWNER/REPO/extra/part?key=value#fragment",
192 want: "git clone https://github.com/OWNER/REPO.git",
193 },
194 {
195 name: "SSH URL",
196 args: "git@github.com:OWNER/REPO.git",
197 sshURL: "git@github.com:OWNER/REPO.git",
198 want: "git clone git@github.com:OWNER/REPO.git",
199 },
200 {
201 name: "GitHub.com SSH certificate authority URL",
202 args: "OWNER/REPO",
203 sshURL: "org-1234@github.com:OWNER/REPO.git",
204 gitProtocol: "ssh",
205 want: "git clone org-1234@github.com:OWNER/REPO.git",
206 },
207 {
208 name: "GHE.com SSH certificate authority URL",
209 args: "test-prodweu01@test-prodweu01.ghe.com:OWNER/REPO.git",
210 sshURL: "test-prodweu01_1234@test-prodweu01.ghe.com:OWNER/REPO.git",
211 want: "git clone test-prodweu01_1234@test-prodweu01.ghe.com:OWNER/REPO.git",
212 },
213 {

Callers

nothing calls this directly

Calls 12

VerifyMethod · 0.95
RegisterMethod · 0.95
GraphQLFunction · 0.92
StringResponseFunction · 0.92
StubFunction · 0.92
NewMockConfigFunction · 0.92
EqualMethod · 0.80
StderrMethod · 0.80
RunMethod · 0.65
SetMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected