Skip to content

Commit

Permalink
Resource Tested for JSON marshalling : App
Browse files Browse the repository at this point in the history
  • Loading branch information
sagar23sj committed Jun 27, 2021
1 parent 767a8d1 commit 72c1cc9
Showing 1 changed file with 140 additions and 0 deletions.
140 changes: 140 additions & 0 deletions github/apps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1084,3 +1084,143 @@ func TestInstallationToken_Marshal(t *testing.T) {

testJSONMarshal(t, u, want)
}

func TestApp_Marshal(t *testing.T) {
testJSONMarshal(t, &App{}, "{}")

u := &App{
ID: Int64(1),
Slug: String("s"),
NodeID: String("nid"),
Owner: &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},
},
Name: String("n"),
Description: String("d"),
ExternalURL: String("eu"),
HTMLURL: String("hu"),
CreatedAt: &Timestamp{referenceTime},
UpdatedAt: &Timestamp{referenceTime},
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"),
},
Events: []string{"s"},
}

want := `{
"id": 1,
"slug": "s",
"node_id": "nid",
"owner": {
"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"
},
"name": "n",
"description": "d",
"external_url": "eu",
"html_url": "hu",
"created_at": ` + referenceTimeStr + `,
"updated_at": ` + referenceTimeStr + `,
"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"
},
"events": ["s"]
}`

testJSONMarshal(t, u, want)
}

0 comments on commit 72c1cc9

Please sign in to comment.