+
Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
296 changes: 296 additions & 0 deletions github/issues_events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,299 @@ func TestIssuesService_GetEvent(t *testing.T) {
return resp, err
})
}

func TestRename_Marshal(t *testing.T) {
testJSONMarshal(t, &Rename{}, "{}")

u := &Rename{
From: String("from"),
To: String("to"),
}

want := `{
"from": "from",
"to": "to"
}`

testJSONMarshal(t, u, want)
}

func TestDismissedReview_Marshal(t *testing.T) {
testJSONMarshal(t, &DismissedReview{}, "{}")

u := &DismissedReview{
State: String("state"),
ReviewID: Int64(1),
DismissalMessage: String("dm"),
DismissalCommitID: String("dcid"),
}

want := `{
"state": "state",
"review_id": 1,
"dismissal_message": "dm",
"dismissal_commit_id": "dcid"
}`

testJSONMarshal(t, u, want)
}

func TestIssueEvent_Marshal(t *testing.T) {
testJSONMarshal(t, &IssueEvent{}, "{}")

u := &IssueEvent{
ID: Int64(1),
URL: String("url"),
Actor: &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},
},
Event: String("event"),
CreatedAt: &referenceTime,
Issue: &Issue{ID: Int64(1)},
Assignee: &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},
},
Assigner: &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},
},
CommitID: String("cid"),
Milestone: &Milestone{ID: Int64(1)},
Label: &Label{ID: Int64(1)},
Rename: &Rename{
From: String("from"),
To: String("to"),
},
LockReason: String("lr"),
ProjectCard: &ProjectCard{ID: Int64(1)},
DismissedReview: &DismissedReview{
State: String("state"),
ReviewID: Int64(1),
DismissalMessage: String("dm"),
DismissalCommitID: String("dcid"),
},
RequestedReviewer: &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},
},
ReviewRequester: &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},
},
}

want := `{
"id": 1,
"url": "url",
"actor": {
"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"
},
"event": "event",
"created_at": ` + referenceTimeStr + `,
"issue": {
"id": 1
},
"assignee": {
"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"
},
"assigner": {
"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"
},
"commit_id": "cid",
"milestone": {
"id": 1
},
"label": {
"id": 1
},
"rename": {
"from": "from",
"to": "to"
},
"lock_reason": "lr",
"project_card": {
"id": 1
},
"dismissed_review": {
"state": "state",
"review_id": 1,
"dismissal_message": "dm",
"dismissal_commit_id": "dcid"
},
"requested_reviewer": {
"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"
},
"review_requester": {
"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"
}
}`

testJSONMarshal(t, u, want)
}
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载