(t *testing.T)
| 585 | } |
| 586 | |
| 587 | func 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\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\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\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, |
nothing calls this directly
no test coverage detected