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

Function TestShortcutURL

pkg/cmd/issue/artifact/shared/content_test.go:236–335  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

234}
235
236func TestShortcutURL(t *testing.T) {
237 const runbook = "https://github.com/monalisa/monas-cafe/wiki/OAuth-runbook"
238
239 tests := []struct {
240 name string
241 content string
242 want string
243 wantErr string
244 wantErrIs error
245 }{
246 {
247 name: "a shortcut as gh writes it",
248 content: "[InternetShortcut]\r\nURL=" + runbook + "\r\n",
249 want: runbook,
250 },
251 {
252 name: "Unix line endings",
253 content: "[InternetShortcut]\nURL=" + runbook + "\n",
254 want: runbook,
255 },
256 {
257 name: "a shortcut saved by a browser on Windows",
258 content: "\ufeff[{000214A0-0000-0000-C000-000000000046}]\r\nProp3=19,11\r\n[InternetShortcut]\r\nIDList=\r\n" +
259 "URL=https://github.com/monalisa/monas-cafe/wiki/OAuth-runbook#staging\r\nIconIndex=0\r\n",
260 want: "https://github.com/monalisa/monas-cafe/wiki/OAuth-runbook#staging",
261 },
262 {
263 name: "any case, with spaces around the key and value",
264 content: "[internetshortcut]\n url = " + runbook + " \n",
265 want: runbook,
266 },
267 {
268 name: "comments and blank lines are ignored",
269 content: "; saved by gh\n\n[InternetShortcut]\n; the runbook\nURL=" + runbook + "\n",
270 want: runbook,
271 },
272 {
273 name: "the first URL wins",
274 content: "[InternetShortcut]\nURL=" + runbook + "\nURL=https://github.com/monalisa/monas-cafe\n",
275 want: runbook,
276 },
277 {
278 name: "a URL in another section is ignored",
279 content: "[Other]\nURL=https://monas-cafe.example/other\n[InternetShortcut]\nURL=" + runbook + "\n",
280 want: runbook,
281 },
282 {
283 name: "a later section doesn't change the URL",
284 content: "[InternetShortcut]\nURL=" + runbook + "\n[InternetShortcut.W]\nURL=+AGgAdA-\n",
285 want: runbook,
286 },
287 {
288 name: "a bare URL",
289 content: runbook + "\n",
290 wantErrIs: ErrNoShortcutSection,
291 },
292 {
293 name: "only a URL in another section",

Callers

nothing calls this directly

Calls 3

ShortcutURLFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected