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

Function TestCreate

pkg/cmd/issue/artifact/client/client_test.go:587–705  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

585}
586
587func TestCreate(t *testing.T) {
588 createdAt := time.Date(2026, 9, 24, 21, 0, 0, 0, time.UTC)
589
590 tests := []struct {
591 name string
592 repo ghrepo.Interface
593 artifactType string
594 artifactName string
595 body string
596 status int
597 response string
598 want *Artifact
599 wantURL string
600 wantErr string
601 }{
602 {
603 name: "creates a document and decodes the new artifact",
604 repo: ghrepo.New("monalisa", "monas-cafe"),
605 artifactType: "generic",
606 artifactName: "signin-plan.md",
607 body: "# Sign-in plan\n\n![Sign-in flow](./signin-flow.png)\n",
608 status: 201,
609 response: `{
610 "id": 6630,
611 "number": 6,
612 "type": "generic",
613 "name": "signin-plan.md",
614 "body": "# Sign-in plan\n\n![Sign-in flow](./signin-flow.png)\n",
615 "body_html": "<h1>Sign-in plan</h1>",
616 "creator": {"login": "monalisa", "id": 1},
617 "updated_by_actor": {"login": "monalisa", "id": 1},
618 "created_at": "2026-09-24T21:00:00Z",
619 "updated_at": "2026-09-24T21:00:00Z"
620 }`,
621 want: &Artifact{
622 ID: 6630,
623 Number: 6,
624 Type: "generic",
625 Name: "signin-plan.md",
626 Body: "# Sign-in plan\n\n![Sign-in flow](./signin-flow.png)\n",
627 BodyHTML: "<h1>Sign-in plan</h1>",
628 Creator: &Actor{ID: 1, Login: "monalisa"},
629 UpdatedByActor: &Actor{ID: 1, Login: "monalisa"},
630 CreatedAt: &createdAt,
631 UpdatedAt: &createdAt,
632 },
633 wantURL: "https://api.github.com/repos/monalisa/monas-cafe/issues/142/artifacts",
634 },
635 {
636 name: "creates a link",
637 repo: ghrepo.New("monalisa", "monas-cafe"),
638 artifactType: "link",
639 artifactName: "Staging OAuth runbook",
640 body: "https://github.com/monalisa/monas-cafe/wiki/OAuth-runbook",
641 status: 201,
642 response: `{"id": 6631, "number": 7, "type": "link", "name": "Staging OAuth runbook", "body": "https://github.com/monalisa/monas-cafe/wiki/OAuth-runbook"}`,
643 want: &Artifact{
644 ID: 6631,

Callers

nothing calls this directly

Calls 12

VerifyMethod · 0.95
RegisterMethod · 0.95
CreateMethod · 0.95
NewFunction · 0.92
NewWithHostFunction · 0.92
RESTFunction · 0.92
RESTPayloadFunction · 0.92
NewArtifactClientFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65
LenMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected