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

Function Test_GistClone

pkg/cmd/gist/clone/clone_test.go:57–114  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

55}
56
57func Test_GistClone(t *testing.T) {
58 tests := []struct {
59 name string
60 args string
61 want string
62 }{
63 {
64 name: "shorthand",
65 args: "GIST",
66 want: "git clone https://gist.github.com/GIST.git",
67 },
68 {
69 name: "shorthand with directory",
70 args: "GIST target_directory",
71 want: "git clone https://gist.github.com/GIST.git target_directory",
72 },
73 {
74 name: "clone arguments",
75 args: "GIST -- -o upstream --depth 1",
76 want: "git clone -o upstream --depth 1 https://gist.github.com/GIST.git",
77 },
78 {
79 name: "clone arguments with directory",
80 args: "GIST target_directory -- -o upstream --depth 1",
81 want: "git clone -o upstream --depth 1 https://gist.github.com/GIST.git target_directory",
82 },
83 {
84 name: "HTTPS URL",
85 args: "https://gist.github.com/OWNER/GIST",
86 want: "git clone https://gist.github.com/OWNER/GIST",
87 },
88 {
89 name: "SSH URL",
90 args: "git@gist.github.com:GIST.git",
91 want: "git clone git@gist.github.com:GIST.git",
92 },
93 }
94 for _, tt := range tests {
95 t.Run(tt.name, func(t *testing.T) {
96 reg := &httpmock.Registry{}
97 defer reg.Verify(t)
98
99 httpClient := &http.Client{Transport: reg}
100
101 cs, restore := run.Stub()
102 defer restore(t)
103 cs.Register(tt.want, 0, "")
104
105 output, err := runCloneCommand(httpClient, tt.args)
106 if err != nil {
107 t.Fatalf("error running command `gist clone`: %v", err)
108 }
109
110 assert.Equal(t, "", output.String())
111 assert.Equal(t, "", output.Stderr())
112 })
113 }
114}

Callers

nothing calls this directly

Calls 8

VerifyMethod · 0.95
StubFunction · 0.92
EqualMethod · 0.80
StderrMethod · 0.80
runCloneCommandFunction · 0.70
RunMethod · 0.65
StringMethod · 0.65
RegisterMethod · 0.45

Tested by

no test coverage detected