diff --git a/github/event.go b/github/event.go index 9241d0286d8..136abb273d8 100644 --- a/github/event.go +++ b/github/event.go @@ -50,6 +50,8 @@ func (e *Event) ParsePayload() (payload interface{}, err error) { payload = &DeploymentEvent{} case "DeploymentStatusEvent": payload = &DeploymentStatusEvent{} + case "DiscussionEvent": + payload = &DiscussionEvent{} case "ForkEvent": payload = &ForkEvent{} case "GitHubAppAuthorizationEvent": diff --git a/github/event_types.go b/github/event_types.go index f63c8040336..eb1e78d906d 100644 --- a/github/event_types.go +++ b/github/event_types.go @@ -180,6 +180,59 @@ type DeploymentStatusEvent struct { Installation *Installation `json:"installation,omitempty"` } +// DiscussionEvent represents a webhook event for a discussion. +// The Webhook event name is "discussion". +// +// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#discussion +type DiscussionEvent struct { + // Action is the action that was performed. Possible values are: + // created, edited, deleted, pinned, unpinned, locked, unlocked, + // transferred, category_changed, answered, or unanswered. + Action *string `json:"action,omitempty"` + Discussion *Discussion `json:"discussion,omitempty"` + Repo *Repository `json:"repository,omitempty"` + Org *Organization `json:"organization,omitempty"` + Sender *User `json:"sender,omitempty"` + Installation *Installation `json:"installation,omitempty"` +} + +// Discussion represents a discussion in a GitHub DiscussionEvent. +type Discussion struct { + RepositoryURL *string `json:"repository_url,omitempty"` + DiscussionCategory *DiscussionCategory `json:"category,omitempty"` + AnswerHTMLURL *string `json:"answer_html_url,omitempty"` + AnswerChosenAt *Timestamp `json:"answer_chosen_at,omitempty"` + AnswerChosenBy *string `json:"answer_chosen_by,omitempty"` + HTMLURL *string `json:"html_url,omitempty"` + ID *int64 `json:"id,omitempty"` + NodeID *string `json:"node_id,omitempty"` + Number *int `json:"number,omitempty"` + Title *string `json:"title,omitempty"` + User *User `json:"user,omitempty"` + State *string `json:"state,omitempty"` + Locked *bool `json:"locked,omitempty"` + Comments *int `json:"comments,omitempty"` + CreatedAt *Timestamp `json:"created_at,omitempty"` + UpdatedAt *Timestamp `json:"updated_at,omitempty"` + AuthorAssociation *string `json:"author_association,omitempty"` + ActiveLockReason *string `json:"active_lock_reason,omitempty"` + Body *string `json:"body,omitempty"` +} + +// DiscussionCategory represents a discussion category in a GitHub DiscussionEvent. +type DiscussionCategory struct { + ID *int64 `json:"id,omitempty"` + NodeID *string `json:"node_id,omitempty"` + RepositoryID *int64 `json:"repository_id,omitempty"` + Emoji *string `json:"emoji,omitempty"` + Name *string `json:"name,omitempty"` + Description *string `json:"description,omitempty"` + CreatedAt *Timestamp `json:"created_at,omitempty"` + UpdatedAt *Timestamp `json:"updated_at,omitempty"` + Slug *string `json:"slug,omitempty"` + IsAnswerable *bool `json:"is_answerable,omitempty"` +} + // ForkEvent is triggered when a user forks a repository. // The Webhook event name is "fork". // diff --git a/github/event_types_test.go b/github/event_types_test.go index d7113b5594f..3aac1763196 100644 --- a/github/event_types_test.go +++ b/github/event_types_test.go @@ -5718,6 +5718,352 @@ func TestDeploymentStatusEvent_Marshal(t *testing.T) { testJSONMarshal(t, u, want) } +func TestDiscussionEvent_Marshal(t *testing.T) { + testJSONMarshal(t, &DiscussionEvent{}, "{}") + + u := &DiscussionEvent{ + Discussion: &Discussion{ + RepositoryURL: String("rurl"), + DiscussionCategory: &DiscussionCategory{ + ID: Int64(1), + NodeID: String("nid"), + RepositoryID: Int64(1), + Emoji: String("emoji"), + Name: String("name"), + Description: String("description"), + CreatedAt: &Timestamp{referenceTime}, + UpdatedAt: &Timestamp{referenceTime}, + Slug: String("slug"), + IsAnswerable: Bool(false), + }, + HTMLURL: String("hurl"), + ID: Int64(1), + NodeID: String("nurl"), + Number: Int(1), + Title: String("title"), + User: &User{ + Login: String("l"), + ID: Int64(1), + NodeID: String("n"), + URL: String("u"), + ReposURL: String("r"), + EventsURL: String("e"), + AvatarURL: String("a"), + }, + State: String("st"), + Locked: Bool(false), + Comments: Int(1), + CreatedAt: &Timestamp{referenceTime}, + UpdatedAt: &Timestamp{referenceTime}, + AuthorAssociation: String("aa"), + Body: String("bo"), + }, + Repo: &Repository{ + ID: Int64(1), + URL: String("s"), + Name: String("n"), + }, + Org: &Organization{ + BillingEmail: String("be"), + Blog: String("b"), + Company: String("c"), + Email: String("e"), + TwitterUsername: String("tu"), + Location: String("loc"), + Name: String("n"), + Description: String("d"), + IsVerified: Bool(true), + HasOrganizationProjects: Bool(true), + HasRepositoryProjects: Bool(true), + DefaultRepoPermission: String("drp"), + MembersCanCreateRepos: Bool(true), + MembersCanCreateInternalRepos: Bool(true), + MembersCanCreatePrivateRepos: Bool(true), + MembersCanCreatePublicRepos: Bool(false), + MembersAllowedRepositoryCreationType: String("marct"), + MembersCanCreatePages: Bool(true), + MembersCanCreatePublicPages: Bool(false), + MembersCanCreatePrivatePages: Bool(true), + }, + Sender: &User{ + Login: String("l"), + ID: Int64(1), + NodeID: String("n"), + URL: String("u"), + ReposURL: String("r"), + EventsURL: String("e"), + AvatarURL: String("a"), + }, + Installation: &Installation{ + ID: Int64(1), + NodeID: String("nid"), + AppID: Int64(1), + AppSlug: String("as"), + TargetID: Int64(1), + Account: &User{ + Login: String("l"), + ID: Int64(1), + URL: String("u"), + AvatarURL: String("a"), + GravatarID: String("g"), + Name: String("n"), + Company: String("c"), + Blog: String("b"), + Location: String("l"), + Email: String("e"), + Hireable: Bool(true), + Bio: String("b"), + TwitterUsername: String("t"), + PublicRepos: Int(1), + Followers: Int(1), + Following: Int(1), + CreatedAt: &Timestamp{referenceTime}, + SuspendedAt: &Timestamp{referenceTime}, + }, + AccessTokensURL: String("atu"), + RepositoriesURL: String("ru"), + HTMLURL: String("hu"), + TargetType: String("tt"), + SingleFileName: String("sfn"), + RepositorySelection: String("rs"), + Events: []string{"e"}, + SingleFilePaths: []string{"s"}, + Permissions: &InstallationPermissions{ + Actions: String("a"), + Administration: String("ad"), + Checks: String("c"), + Contents: String("co"), + ContentReferences: String("cr"), + Deployments: String("d"), + Environments: String("e"), + Issues: String("i"), + Metadata: String("md"), + Members: String("m"), + OrganizationAdministration: String("oa"), + OrganizationHooks: String("oh"), + OrganizationPlan: String("op"), + OrganizationPreReceiveHooks: String("opr"), + OrganizationProjects: String("op"), + OrganizationSecrets: String("os"), + OrganizationSelfHostedRunners: String("osh"), + OrganizationUserBlocking: String("oub"), + Packages: String("pkg"), + Pages: String("pg"), + PullRequests: String("pr"), + RepositoryHooks: String("rh"), + RepositoryProjects: String("rp"), + RepositoryPreReceiveHooks: String("rprh"), + Secrets: String("s"), + SecretScanningAlerts: String("ssa"), + SecurityEvents: String("se"), + SingleFile: String("sf"), + Statuses: String("s"), + TeamDiscussions: String("td"), + VulnerabilityAlerts: String("va"), + Workflows: String("w"), + }, + CreatedAt: &Timestamp{referenceTime}, + UpdatedAt: &Timestamp{referenceTime}, + HasMultipleSingleFiles: Bool(false), + SuspendedBy: &User{ + Login: String("l"), + ID: Int64(1), + URL: String("u"), + AvatarURL: String("a"), + GravatarID: String("g"), + Name: String("n"), + Company: String("c"), + Blog: String("b"), + Location: String("l"), + Email: String("e"), + Hireable: Bool(true), + Bio: String("b"), + TwitterUsername: String("t"), + PublicRepos: Int(1), + Followers: Int(1), + Following: Int(1), + CreatedAt: &Timestamp{referenceTime}, + SuspendedAt: &Timestamp{referenceTime}, + }, + SuspendedAt: &Timestamp{referenceTime}, + }, + } + + want := `{ + "discussion": { + "repository_url": "rurl", + "category": { + "id": 1, + "node_id": "nid", + "repository_id": 1, + "emoji": "emoji", + "name": "name", + "description": "description", + "created_at": ` + referenceTimeStr + `, + "updated_at": ` + referenceTimeStr + `, + "slug": "slug", + "is_answerable": false + }, + "html_url": "hurl", + "id": 1, + "node_id": "nurl", + "number": 1, + "title": "title", + "user": { + "login": "l", + "id": 1, + "node_id": "n", + "avatar_url": "a", + "url": "u", + "events_url": "e", + "repos_url": "r" + }, + "state": "st", + "locked": false, + "comments": 1, + "created_at": ` + referenceTimeStr + `, + "updated_at": ` + referenceTimeStr + `, + "author_association": "aa", + "body": "bo" + }, + "repository": { + "id": 1, + "name": "n", + "url": "s" + }, + "organization": { + "name": "n", + "company": "c", + "blog": "b", + "location": "loc", + "email": "e", + "twitter_username": "tu", + "description": "d", + "billing_email": "be", + "is_verified": true, + "has_organization_projects": true, + "has_repository_projects": true, + "default_repository_permission": "drp", + "members_can_create_repositories": true, + "members_can_create_public_repositories": false, + "members_can_create_private_repositories": true, + "members_can_create_internal_repositories": true, + "members_allowed_repository_creation_type": "marct", + "members_can_create_pages": true, + "members_can_create_public_pages": false, + "members_can_create_private_pages": true + }, + "sender": { + "login": "l", + "id": 1, + "node_id": "n", + "avatar_url": "a", + "url": "u", + "events_url": "e", + "repos_url": "r" + }, + "installation": { + "id": 1, + "node_id": "nid", + "app_id": 1, + "app_slug": "as", + "target_id": 1, + "account": { + "login": "l", + "id": 1, + "avatar_url": "a", + "gravatar_id": "g", + "name": "n", + "company": "c", + "blog": "b", + "location": "l", + "email": "e", + "hireable": true, + "bio": "b", + "twitter_username": "t", + "public_repos": 1, + "followers": 1, + "following": 1, + "created_at": ` + referenceTimeStr + `, + "suspended_at": ` + referenceTimeStr + `, + "url": "u" + }, + "access_tokens_url": "atu", + "repositories_url": "ru", + "html_url": "hu", + "target_type": "tt", + "single_file_name": "sfn", + "repository_selection": "rs", + "events": [ + "e" + ], + "single_file_paths": [ + "s" + ], + "permissions": { + "actions": "a", + "administration": "ad", + "checks": "c", + "contents": "co", + "content_references": "cr", + "deployments": "d", + "environments": "e", + "issues": "i", + "metadata": "md", + "members": "m", + "organization_administration": "oa", + "organization_hooks": "oh", + "organization_plan": "op", + "organization_pre_receive_hooks": "opr", + "organization_projects": "op", + "organization_secrets": "os", + "organization_self_hosted_runners": "osh", + "organization_user_blocking": "oub", + "packages": "pkg", + "pages": "pg", + "pull_requests": "pr", + "repository_hooks": "rh", + "repository_projects": "rp", + "repository_pre_receive_hooks": "rprh", + "secrets": "s", + "secret_scanning_alerts": "ssa", + "security_events": "se", + "single_file": "sf", + "statuses": "s", + "team_discussions": "td", + "vulnerability_alerts": "va", + "workflows": "w" + }, + "created_at": ` + referenceTimeStr + `, + "updated_at": ` + referenceTimeStr + `, + "has_multiple_single_files": false, + "suspended_by": { + "login": "l", + "id": 1, + "avatar_url": "a", + "gravatar_id": "g", + "name": "n", + "company": "c", + "blog": "b", + "location": "l", + "email": "e", + "hireable": true, + "bio": "b", + "twitter_username": "t", + "public_repos": 1, + "followers": 1, + "following": 1, + "created_at": ` + referenceTimeStr + `, + "suspended_at": ` + referenceTimeStr + `, + "url": "u" + }, + "suspended_at": ` + referenceTimeStr + ` + } + }` + + testJSONMarshal(t, u, want) +} + func TestPackageEvent_Marshal(t *testing.T) { testJSONMarshal(t, &PackageEvent{}, "{}") diff --git a/github/github-accessors.go b/github/github-accessors.go index 166e2ad50c3..19cadfc000d 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -3844,6 +3844,238 @@ func (d *DeploymentStatusRequest) GetState() string { return *d.State } +// GetActiveLockReason returns the ActiveLockReason field if it's non-nil, zero value otherwise. +func (d *Discussion) GetActiveLockReason() string { + if d == nil || d.ActiveLockReason == nil { + return "" + } + return *d.ActiveLockReason +} + +// GetAnswerChosenAt returns the AnswerChosenAt field if it's non-nil, zero value otherwise. +func (d *Discussion) GetAnswerChosenAt() Timestamp { + if d == nil || d.AnswerChosenAt == nil { + return Timestamp{} + } + return *d.AnswerChosenAt +} + +// GetAnswerChosenBy returns the AnswerChosenBy field if it's non-nil, zero value otherwise. +func (d *Discussion) GetAnswerChosenBy() string { + if d == nil || d.AnswerChosenBy == nil { + return "" + } + return *d.AnswerChosenBy +} + +// GetAnswerHTMLURL returns the AnswerHTMLURL field if it's non-nil, zero value otherwise. +func (d *Discussion) GetAnswerHTMLURL() string { + if d == nil || d.AnswerHTMLURL == nil { + return "" + } + return *d.AnswerHTMLURL +} + +// GetAuthorAssociation returns the AuthorAssociation field if it's non-nil, zero value otherwise. +func (d *Discussion) GetAuthorAssociation() string { + if d == nil || d.AuthorAssociation == nil { + return "" + } + return *d.AuthorAssociation +} + +// GetBody returns the Body field if it's non-nil, zero value otherwise. +func (d *Discussion) GetBody() string { + if d == nil || d.Body == nil { + return "" + } + return *d.Body +} + +// GetComments returns the Comments field if it's non-nil, zero value otherwise. +func (d *Discussion) GetComments() int { + if d == nil || d.Comments == nil { + return 0 + } + return *d.Comments +} + +// GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. +func (d *Discussion) GetCreatedAt() Timestamp { + if d == nil || d.CreatedAt == nil { + return Timestamp{} + } + return *d.CreatedAt +} + +// GetDiscussionCategory returns the DiscussionCategory field. +func (d *Discussion) GetDiscussionCategory() *DiscussionCategory { + if d == nil { + return nil + } + return d.DiscussionCategory +} + +// GetHTMLURL returns the HTMLURL field if it's non-nil, zero value otherwise. +func (d *Discussion) GetHTMLURL() string { + if d == nil || d.HTMLURL == nil { + return "" + } + return *d.HTMLURL +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (d *Discussion) GetID() int64 { + if d == nil || d.ID == nil { + return 0 + } + return *d.ID +} + +// GetLocked returns the Locked field if it's non-nil, zero value otherwise. +func (d *Discussion) GetLocked() bool { + if d == nil || d.Locked == nil { + return false + } + return *d.Locked +} + +// GetNodeID returns the NodeID field if it's non-nil, zero value otherwise. +func (d *Discussion) GetNodeID() string { + if d == nil || d.NodeID == nil { + return "" + } + return *d.NodeID +} + +// GetNumber returns the Number field if it's non-nil, zero value otherwise. +func (d *Discussion) GetNumber() int { + if d == nil || d.Number == nil { + return 0 + } + return *d.Number +} + +// GetRepositoryURL returns the RepositoryURL field if it's non-nil, zero value otherwise. +func (d *Discussion) GetRepositoryURL() string { + if d == nil || d.RepositoryURL == nil { + return "" + } + return *d.RepositoryURL +} + +// GetState returns the State field if it's non-nil, zero value otherwise. +func (d *Discussion) GetState() string { + if d == nil || d.State == nil { + return "" + } + return *d.State +} + +// GetTitle returns the Title field if it's non-nil, zero value otherwise. +func (d *Discussion) GetTitle() string { + if d == nil || d.Title == nil { + return "" + } + return *d.Title +} + +// GetUpdatedAt returns the UpdatedAt field if it's non-nil, zero value otherwise. +func (d *Discussion) GetUpdatedAt() Timestamp { + if d == nil || d.UpdatedAt == nil { + return Timestamp{} + } + return *d.UpdatedAt +} + +// GetUser returns the User field. +func (d *Discussion) GetUser() *User { + if d == nil { + return nil + } + return d.User +} + +// GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. +func (d *DiscussionCategory) GetCreatedAt() Timestamp { + if d == nil || d.CreatedAt == nil { + return Timestamp{} + } + return *d.CreatedAt +} + +// GetDescription returns the Description field if it's non-nil, zero value otherwise. +func (d *DiscussionCategory) GetDescription() string { + if d == nil || d.Description == nil { + return "" + } + return *d.Description +} + +// GetEmoji returns the Emoji field if it's non-nil, zero value otherwise. +func (d *DiscussionCategory) GetEmoji() string { + if d == nil || d.Emoji == nil { + return "" + } + return *d.Emoji +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (d *DiscussionCategory) GetID() int64 { + if d == nil || d.ID == nil { + return 0 + } + return *d.ID +} + +// GetIsAnswerable returns the IsAnswerable field if it's non-nil, zero value otherwise. +func (d *DiscussionCategory) GetIsAnswerable() bool { + if d == nil || d.IsAnswerable == nil { + return false + } + return *d.IsAnswerable +} + +// GetName returns the Name field if it's non-nil, zero value otherwise. +func (d *DiscussionCategory) GetName() string { + if d == nil || d.Name == nil { + return "" + } + return *d.Name +} + +// GetNodeID returns the NodeID field if it's non-nil, zero value otherwise. +func (d *DiscussionCategory) GetNodeID() string { + if d == nil || d.NodeID == nil { + return "" + } + return *d.NodeID +} + +// GetRepositoryID returns the RepositoryID field if it's non-nil, zero value otherwise. +func (d *DiscussionCategory) GetRepositoryID() int64 { + if d == nil || d.RepositoryID == nil { + return 0 + } + return *d.RepositoryID +} + +// GetSlug returns the Slug field if it's non-nil, zero value otherwise. +func (d *DiscussionCategory) GetSlug() string { + if d == nil || d.Slug == nil { + return "" + } + return *d.Slug +} + +// GetUpdatedAt returns the UpdatedAt field if it's non-nil, zero value otherwise. +func (d *DiscussionCategory) GetUpdatedAt() Timestamp { + if d == nil || d.UpdatedAt == nil { + return Timestamp{} + } + return *d.UpdatedAt +} + // GetAuthor returns the Author field. func (d *DiscussionComment) GetAuthor() *User { if d == nil { @@ -3948,6 +4180,54 @@ func (d *DiscussionComment) GetURL() string { return *d.URL } +// GetAction returns the Action field if it's non-nil, zero value otherwise. +func (d *DiscussionEvent) GetAction() string { + if d == nil || d.Action == nil { + return "" + } + return *d.Action +} + +// GetDiscussion returns the Discussion field. +func (d *DiscussionEvent) GetDiscussion() *Discussion { + if d == nil { + return nil + } + return d.Discussion +} + +// GetInstallation returns the Installation field. +func (d *DiscussionEvent) GetInstallation() *Installation { + if d == nil { + return nil + } + return d.Installation +} + +// GetOrg returns the Org field. +func (d *DiscussionEvent) GetOrg() *Organization { + if d == nil { + return nil + } + return d.Org +} + +// GetRepo returns the Repo field. +func (d *DiscussionEvent) GetRepo() *Repository { + if d == nil { + return nil + } + return d.Repo +} + +// GetSender returns the Sender field. +func (d *DiscussionEvent) GetSender() *User { + if d == nil { + return nil + } + return d.Sender +} + // GetTeams returns the Teams field if it's non-nil, zero value otherwise. func (d *DismissalRestrictionsRequest) GetTeams() []string { if d == nil || d.Teams == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index fa4dc56c397..2ecb50033ae 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -4494,6 +4494,290 @@ func TestDeploymentStatusRequest_GetState(tt *testing.T) { d.GetState() } +func TestDiscussion_GetActiveLockReason(tt *testing.T) { + var zeroValue string + d := &Discussion{ActiveLockReason: &zeroValue} + d.GetActiveLockReason() + d = &Discussion{} + d.GetActiveLockReason() + d = nil + d.GetActiveLockReason() +} + +func TestDiscussion_GetAnswerChosenAt(tt *testing.T) { + var zeroValue Timestamp + d := &Discussion{AnswerChosenAt: &zeroValue} + d.GetAnswerChosenAt() + d = &Discussion{} + d.GetAnswerChosenAt() + d = nil + d.GetAnswerChosenAt() +} + +func TestDiscussion_GetAnswerChosenBy(tt *testing.T) { + var zeroValue string + d := &Discussion{AnswerChosenBy: &zeroValue} + d.GetAnswerChosenBy() + d = &Discussion{} + d.GetAnswerChosenBy() + d = nil + d.GetAnswerChosenBy() +} + +func TestDiscussion_GetAnswerHTMLURL(tt *testing.T) { + var zeroValue string + d := &Discussion{AnswerHTMLURL: &zeroValue} + d.GetAnswerHTMLURL() + d = &Discussion{} + d.GetAnswerHTMLURL() + d = nil + d.GetAnswerHTMLURL() +} + +func TestDiscussion_GetAuthorAssociation(tt *testing.T) { + var zeroValue string + d := &Discussion{AuthorAssociation: &zeroValue} + d.GetAuthorAssociation() + d = &Discussion{} + d.GetAuthorAssociation() + d = nil + d.GetAuthorAssociation() +} + +func TestDiscussion_GetBody(tt *testing.T) { + var zeroValue string + d := &Discussion{Body: &zeroValue} + d.GetBody() + d = &Discussion{} + d.GetBody() + d = nil + d.GetBody() +} + +func TestDiscussion_GetComments(tt *testing.T) { + var zeroValue int + d := &Discussion{Comments: &zeroValue} + d.GetComments() + d = &Discussion{} + d.GetComments() + d = nil + d.GetComments() +} + +func TestDiscussion_GetCreatedAt(tt *testing.T) { + var zeroValue Timestamp + d := &Discussion{CreatedAt: &zeroValue} + d.GetCreatedAt() + d = &Discussion{} + d.GetCreatedAt() + d = nil + d.GetCreatedAt() +} + +func TestDiscussion_GetDiscussionCategory(tt *testing.T) { + d := &Discussion{} + d.GetDiscussionCategory() + d = nil + d.GetDiscussionCategory() +} + +func TestDiscussion_GetHTMLURL(tt *testing.T) { + var zeroValue string + d := &Discussion{HTMLURL: &zeroValue} + d.GetHTMLURL() + d = &Discussion{} + d.GetHTMLURL() + d = nil + d.GetHTMLURL() +} + +func TestDiscussion_GetID(tt *testing.T) { + var zeroValue int64 + d := &Discussion{ID: &zeroValue} + d.GetID() + d = &Discussion{} + d.GetID() + d = nil + d.GetID() +} + +func TestDiscussion_GetLocked(tt *testing.T) { + var zeroValue bool + d := &Discussion{Locked: &zeroValue} + d.GetLocked() + d = &Discussion{} + d.GetLocked() + d = nil + d.GetLocked() +} + +func TestDiscussion_GetNodeID(tt *testing.T) { + var zeroValue string + d := &Discussion{NodeID: &zeroValue} + d.GetNodeID() + d = &Discussion{} + d.GetNodeID() + d = nil + d.GetNodeID() +} + +func TestDiscussion_GetNumber(tt *testing.T) { + var zeroValue int + d := &Discussion{Number: &zeroValue} + d.GetNumber() + d = &Discussion{} + d.GetNumber() + d = nil + d.GetNumber() +} + +func TestDiscussion_GetRepositoryURL(tt *testing.T) { + var zeroValue string + d := &Discussion{RepositoryURL: &zeroValue} + d.GetRepositoryURL() + d = &Discussion{} + d.GetRepositoryURL() + d = nil + d.GetRepositoryURL() +} + +func TestDiscussion_GetState(tt *testing.T) { + var zeroValue string + d := &Discussion{State: &zeroValue} + d.GetState() + d = &Discussion{} + d.GetState() + d = nil + d.GetState() +} + +func TestDiscussion_GetTitle(tt *testing.T) { + var zeroValue string + d := &Discussion{Title: &zeroValue} + d.GetTitle() + d = &Discussion{} + d.GetTitle() + d = nil + d.GetTitle() +} + +func TestDiscussion_GetUpdatedAt(tt *testing.T) { + var zeroValue Timestamp + d := &Discussion{UpdatedAt: &zeroValue} + d.GetUpdatedAt() + d = &Discussion{} + d.GetUpdatedAt() + d = nil + d.GetUpdatedAt() +} + +func TestDiscussion_GetUser(tt *testing.T) { + d := &Discussion{} + d.GetUser() + d = nil + d.GetUser() +} + +func TestDiscussionCategory_GetCreatedAt(tt *testing.T) { + var zeroValue Timestamp + d := &DiscussionCategory{CreatedAt: &zeroValue} + d.GetCreatedAt() + d = &DiscussionCategory{} + d.GetCreatedAt() + d = nil + d.GetCreatedAt() +} + +func TestDiscussionCategory_GetDescription(tt *testing.T) { + var zeroValue string + d := &DiscussionCategory{Description: &zeroValue} + d.GetDescription() + d = &DiscussionCategory{} + d.GetDescription() + d = nil + d.GetDescription() +} + +func TestDiscussionCategory_GetEmoji(tt *testing.T) { + var zeroValue string + d := &DiscussionCategory{Emoji: &zeroValue} + d.GetEmoji() + d = &DiscussionCategory{} + d.GetEmoji() + d = nil + d.GetEmoji() +} + +func TestDiscussionCategory_GetID(tt *testing.T) { + var zeroValue int64 + d := &DiscussionCategory{ID: &zeroValue} + d.GetID() + d = &DiscussionCategory{} + d.GetID() + d = nil + d.GetID() +} + +func TestDiscussionCategory_GetIsAnswerable(tt *testing.T) { + var zeroValue bool + d := &DiscussionCategory{IsAnswerable: &zeroValue} + d.GetIsAnswerable() + d = &DiscussionCategory{} + d.GetIsAnswerable() + d = nil + d.GetIsAnswerable() +} + +func TestDiscussionCategory_GetName(tt *testing.T) { + var zeroValue string + d := &DiscussionCategory{Name: &zeroValue} + d.GetName() + d = &DiscussionCategory{} + d.GetName() + d = nil + d.GetName() +} + +func TestDiscussionCategory_GetNodeID(tt *testing.T) { + var zeroValue string + d := &DiscussionCategory{NodeID: &zeroValue} + d.GetNodeID() + d = &DiscussionCategory{} + d.GetNodeID() + d = nil + d.GetNodeID() +} + +func TestDiscussionCategory_GetRepositoryID(tt *testing.T) { + var zeroValue int64 + d := &DiscussionCategory{RepositoryID: &zeroValue} + d.GetRepositoryID() + d = &DiscussionCategory{} + d.GetRepositoryID() + d = nil + d.GetRepositoryID() +} + +func TestDiscussionCategory_GetSlug(tt *testing.T) { + var zeroValue string + d := &DiscussionCategory{Slug: &zeroValue} + d.GetSlug() + d = &DiscussionCategory{} + d.GetSlug() + d = nil + d.GetSlug() +} + +func TestDiscussionCategory_GetUpdatedAt(tt *testing.T) { + var zeroValue Timestamp + d := &DiscussionCategory{UpdatedAt: &zeroValue} + d.GetUpdatedAt() + d = &DiscussionCategory{} + d.GetUpdatedAt() + d = nil + d.GetUpdatedAt() +} + func TestDiscussionComment_GetAuthor(tt *testing.T) { d := &DiscussionComment{} d.GetAuthor() @@ -4618,6 +4902,51 @@ func TestDiscussionComment_GetURL(tt *testing.T) { d.GetURL() } +func TestDiscussionEvent_GetAction(tt *testing.T) { + var zeroValue string + d := &DiscussionEvent{Action: &zeroValue} + d.GetAction() + d = &DiscussionEvent{} + d.GetAction() + d = nil + d.GetAction() +} + +func TestDiscussionEvent_GetDiscussion(tt *testing.T) { + d := &DiscussionEvent{} + d.GetDiscussion() + d = nil + d.GetDiscussion() +} + +func TestDiscussionEvent_GetInstallation(tt *testing.T) { + d := &DiscussionEvent{} + d.GetInstallation() + d = nil + d.GetInstallation() +} + +func TestDiscussionEvent_GetOrg(tt *testing.T) { + d := &DiscussionEvent{} + d.GetOrg() + d = nil + d.GetOrg() +} + +func TestDiscussionEvent_GetRepo(tt *testing.T) { + d := &DiscussionEvent{} + d.GetRepo() + d = nil + d.GetRepo() +} + +func TestDiscussionEvent_GetSender(tt *testing.T) { + d := &DiscussionEvent{} + d.GetSender() + d = nil + d.GetSender() +} + func TestDismissalRestrictionsRequest_GetTeams(tt *testing.T) { var zeroValue []string d := &DismissalRestrictionsRequest{Teams: &zeroValue} diff --git a/github/messages.go b/github/messages.go index bad2605b681..2e69c523e9a 100644 --- a/github/messages.go +++ b/github/messages.go @@ -55,6 +55,7 @@ var ( "deploy_key": "DeployKeyEvent", "deployment": "DeploymentEvent", "deployment_status": "DeploymentStatusEvent", + "discussion": "DiscussionEvent", "fork": "ForkEvent", "github_app_authorization": "GitHubAppAuthorizationEvent", "gollum": "GollumEvent", diff --git a/github/messages_test.go b/github/messages_test.go index 491cbbaf538..b50ad119a73 100644 --- a/github/messages_test.go +++ b/github/messages_test.go @@ -297,11 +297,14 @@ func TestParseWebHook(t *testing.T) { payload: &DeploymentEvent{}, messageType: "deployment", }, - { payload: &DeploymentStatusEvent{}, messageType: "deployment_status", }, + { + payload: &DiscussionEvent{}, + messageType: "discussion", + }, { payload: &ForkEvent{}, messageType: "fork", diff --git a/github/repos_hooks_deliveries_test.go b/github/repos_hooks_deliveries_test.go index 8724e86320d..9ef3675b2f0 100644 --- a/github/repos_hooks_deliveries_test.go +++ b/github/repos_hooks_deliveries_test.go @@ -117,6 +117,7 @@ var hookDeliveryPayloadTypeToStruct = map[string]interface{}{ "deploy_key": &DeployKeyEvent{}, "deployment": &DeploymentEvent{}, "deployment_status": &DeploymentStatusEvent{}, + "discussion": &DiscussionEvent{}, "fork": &ForkEvent{}, "github_app_authorization": &GitHubAppAuthorizationEvent{}, "gollum": &GollumEvent{},