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

Function TestCreateRun

pkg/cmd/issue/artifact/create/create_test.go:570–1577  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

568}
569
570func TestCreateRun(t *testing.T) {
571 apiError := func(status int, message string) error {
572 u, err := url.Parse("https://api.github.com/repos/monalisa/monas-cafe/issues/142/artifacts")
573 require.NoError(t, err)
574 return api.HTTPError{HTTPError: &ghAPI.HTTPError{StatusCode: status, Message: message, RequestURL: u}}
575 }
576 uploaded := func(name, asset string) attachments.UploadStub {
577 return attachments.UploadStub{Name: name, Status: 200, Body: fmt.Sprintf(`{"url": "https://github.com/user-attachments/assets/%s"}`, asset)}
578 }
579 const (
580 signinPlan = "# Sign-in plan\n\n1. Register the callback URL.\n"
581 oauthResearch = "# OAuth research\n\nGitHub is the only provider we need for now.\n"
582 signinPlanFlow = "# Sign-in plan\n\n![Sign-in flow](./signin-flow.png)\n"
583 baristaFlow = "# Barista notes\n\nThe flow in ![Sign-in flow](./signin-flow.png) confused them.\n"
584 shortcut = "[InternetShortcut]\r\nURL=" + runbookURL + "\r\n"
585 menuHTML = "<!doctype html>\n<html>\n<body><h1>Seasonal menu</h1><p>Maple oat latte</p></body>\n</html>\n"
586 // menuHTMLFlow would have its Markdown reference replaced, were it a
587 // Markdown document.
588 menuHTMLFlow = "<h1>Seasonal menu</h1>\n\n![Sign-in flow](./signin-flow.png)\n"
589 )
590
591 tests := []struct {
592 name string
593 repo ghrepo.Interface
594 files map[string]string
595 symlinks map[string]string
596 attach []string
597 uploads []attachments.UploadStub
598 stdin string
599 opts CreateOptions
600 tty bool
601 color bool
602 isPullRequest bool
603 lookupErr error
604 permission string
605 createErrs map[string]error
606 wantCalls []string
607 wantBodies []string
608 wantOps *attachments.UploadResult
609 wantStdout string
610 wantStderr string
611 wantErr string
612 wantErrIs error
613 }{
614 {
615 name: "a file, named after the file",
616 files: map[string]string{"signin-plan.md": signinPlan},
617 opts: CreateOptions{Sources: []source{{kind: fromFile, arg: "signin-plan.md"}}},
618 tty: true,
619 wantCalls: []string{
620 "IsPullRequest monalisa/monas-cafe#142",
621 `Create monalisa/monas-cafe#142 generic "signin-plan.md"`,
622 },
623 wantBodies: []string{signinPlan},
624 wantStdout: "✓ Created artifact 6 (signin-plan.md) on monalisa/monas-cafe#142\n",
625 },
626 {
627 name: "a file with #<name>",

Callers

nothing calls this directly

Calls 15

VerifyMethod · 0.95
CreateCallsMethod · 0.95
NewWithHostFunction · 0.92
NewFunction · 0.92
NewTestAssetsFunction · 0.92
StubUploadToHostFunction · 0.92
TestFunction · 0.92
FullNameFunction · 0.92
BeginTelemetryFunction · 0.92
SetStdinTTYMethod · 0.80
SetStdoutTTYMethod · 0.80

Tested by

no test coverage detected