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

Function TestDeleteRun

pkg/cmd/repo/autolink/delete/delete_test.go:125–335  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

123var errTestAutolinkClientDelete = errors.New("autolink client delete error")
124
125func TestDeleteRun(t *testing.T) {
126 tests := []struct {
127 name string
128 opts *deleteOptions
129 isTTY bool
130 stubDeleter stubAutolinkDeleter
131 stubViewer stubAutolinkViewer
132 prompterStubs func(*prompter.PrompterMock)
133
134 wantStdout string
135 expectedErr error
136 expectedErrMsg string
137 }{
138 {
139 name: "delete",
140 opts: &deleteOptions{
141 ID: "123",
142 },
143 isTTY: true,
144 stubViewer: stubAutolinkViewer{
145 autolink: &shared.Autolink{
146 ID: 123,
147 KeyPrefix: "TICKET-",
148 URLTemplate: "https://example.com/TICKET?query=<num>",
149 IsAlphanumeric: true,
150 },
151 },
152 stubDeleter: stubAutolinkDeleter{
153 err: nil,
154 },
155 prompterStubs: func(pm *prompter.PrompterMock) {
156 pm.ConfirmDeletionFunc = func(_ string) error {
157 return nil
158 }
159 },
160 wantStdout: heredoc.Doc(`
161 Autolink 123 has key prefix TICKET-.
162 ✓ Autolink 123 deleted from OWNER/REPO
163 `),
164 },
165 {
166 name: "delete with confirm flag",
167 opts: &deleteOptions{
168 ID: "123",
169 Confirmed: true,
170 },
171 isTTY: true,
172 stubViewer: stubAutolinkViewer{
173 autolink: &shared.Autolink{
174 ID: 123,
175 KeyPrefix: "TICKET-",
176 URLTemplate: "https://example.com/TICKET?query=<num>",
177 IsAlphanumeric: true,
178 },
179 },
180 stubDeleter: stubAutolinkDeleter{},
181 wantStdout: "✓ Autolink 123 deleted from OWNER/REPO\n",
182 },

Callers

nothing calls this directly

Calls 9

TestFunction · 0.92
NewFunction · 0.92
SetStdinTTYMethod · 0.80
SetStdoutTTYMethod · 0.80
EqualMethod · 0.80
deleteRunFunction · 0.70
RunMethod · 0.65
StringMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected