Skip to content

Commit 3c38412

Browse files
committed
Add test case for JSON resources marshaling (google#2081)
Helps: google#55.
1 parent cdc273b commit 3c38412

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

‎github/repos_invitations_test.go‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,55 @@ func TestRepositoriesService_UpdateInvitation(t *testing.T) {
111111
return resp, err
112112
})
113113
}
114+
115+
func TestRepositoryInvitation_Marshal(t *testing.T) {
116+
testJSONMarshal(t, &RepositoryInvitation{}, "{}")
117+
118+
r := &RepositoryInvitation{
119+
ID: Int64(1),
120+
Repo: &Repository{
121+
ID: Int64(1),
122+
Name: String("n"),
123+
URL: String("u"),
124+
},
125+
Invitee: &User{
126+
ID: Int64(1),
127+
Name: String("n"),
128+
URL: String("u"),
129+
},
130+
Inviter: &User{
131+
ID: Int64(1),
132+
Name: String("n"),
133+
URL: String("u"),
134+
},
135+
Permissions: String("p"),
136+
CreatedAt: &Timestamp{referenceTime},
137+
URL: String("u"),
138+
HTMLURL: String("h"),
139+
}
140+
141+
want := `{
142+
"id":1,
143+
"repository":{
144+
"id":1,
145+
"name":"n",
146+
"url":"u"
147+
},
148+
"invitee":{
149+
"id":1,
150+
"name":"n",
151+
"url":"u"
152+
},
153+
"inviter":{
154+
"id":1,
155+
"name":"n",
156+
"url":"u"
157+
},
158+
"permissions":"p",
159+
"created_at":` + referenceTimeStr + `,
160+
"url":"u",
161+
"html_url":"h"
162+
}`
163+
164+
testJSONMarshal(t, r, want)
165+
}

0 commit comments

Comments
 (0)