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

Function TestUpdate

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

Source from the content-addressed store, hash-verified

705}
706
707func TestUpdate(t *testing.T) {
708 createdAt := time.Date(2026, 9, 21, 23, 0, 0, 0, time.UTC)
709 updatedAt := time.Date(2026, 9, 24, 21, 0, 0, 0, time.UTC)
710 name := "OAuth callback plan v2"
711 body := "# OAuth callback plan\n\n![Sign-in flow](./signin-flow.png)\n"
712 empty := ""
713
714 tests := []struct {
715 name string
716 repo ghrepo.Interface
717 number int
718 newName *string
719 newBody *string
720 status int
721 response string
722 want *Artifact
723 wantPayload map[string]any
724 wantURL string
725 wantErr string
726 }{
727 {
728 name: "renames an artifact and decodes it",
729 repo: ghrepo.New("monalisa", "monas-cafe"),
730 number: 2,
731 newName: &name,
732 status: 200,
733 response: `{
734 "id": 6626,
735 "number": 2,
736 "type": "generic",
737 "name": "OAuth callback plan v2",
738 "body": "# OAuth callback plan",
739 "body_html": "<h1>OAuth callback plan</h1>",
740 "creator": {"login": "hubot", "id": 2},
741 "updated_by_actor": {"login": "monalisa", "id": 1},
742 "created_at": "2026-09-21T23:00:00Z",
743 "updated_at": "2026-09-24T21:00:00Z"
744 }`,
745 want: &Artifact{
746 ID: 6626,
747 Number: 2,
748 Type: "generic",
749 Name: "OAuth callback plan v2",
750 Body: "# OAuth callback plan",
751 BodyHTML: "<h1>OAuth callback plan</h1>",
752 Creator: &Actor{ID: 2, Login: "hubot"},
753 UpdatedByActor: &Actor{ID: 1, Login: "monalisa"},
754 CreatedAt: &createdAt,
755 UpdatedAt: &updatedAt,
756 },
757 wantPayload: map[string]any{"name": "OAuth callback plan v2"},
758 wantURL: "https://api.github.com/repos/monalisa/monas-cafe/issues/142/artifacts/2",
759 },
760 {
761 name: "replaces the body and keeps the name",
762 repo: ghrepo.New("monalisa", "monas-cafe"),
763 number: 2,
764 newBody: &body,

Callers

nothing calls this directly

Calls 12

VerifyMethod · 0.95
RegisterMethod · 0.95
UpdateMethod · 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