diff --git a/github/orgs_members_test.go b/github/orgs_members_test.go index f1d2b49b9e8..442ae13e7d4 100644 --- a/github/orgs_members_test.go +++ b/github/orgs_members_test.go @@ -850,3 +850,107 @@ func TestOrganizationsService_ListFailedOrgInvitations(t *testing.T) { return resp, err }) } + +func TestMembership_Marshal(t *testing.T) { + testJSONMarshal(t, &Membership{}, "{}") + + u := &Membership{ + URL: String("url"), + State: String("state"), + Role: String("email"), + OrganizationURL: String("orgurl"), + Organization: &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), + }, + User: &User{ + Login: String("l"), + ID: Int64(1), + NodeID: String("n"), + URL: String("u"), + ReposURL: String("r"), + EventsURL: String("e"), + AvatarURL: String("a"), + }, + } + + want := `{ + "url": "url", + "state": "state", + "role": "email", + "organization_url": "orgurl", + "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 + }, + "user": { + "login": "l", + "id": 1, + "node_id": "n", + "avatar_url": "a", + "url": "u", + "events_url": "e", + "repos_url": "r" + } + }` + + testJSONMarshal(t, u, want) +} + +func TestCreateOrgInvitationOptions_Marshal(t *testing.T) { + testJSONMarshal(t, &CreateOrgInvitationOptions{}, "{}") + + u := &CreateOrgInvitationOptions{ + InviteeID: Int64(1), + Email: String("email"), + Role: String("role"), + TeamID: []int64{1}, + } + + want := `{ + "invitee_id": 1, + "email": "email", + "role": "role", + "team_ids": [ + 1 + ] + }` + + testJSONMarshal(t, u, want) +}