Skip to content

Commit 0159d75

Browse files
committed
Resource Tested for JSON marshalling : Authorization
1 parent 7f48ac1 commit 0159d75

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

github/authorizations_test.go

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,3 +301,87 @@ func TestGrant_Marshal(t *testing.T) {
301301

302302
testJSONMarshal(t, u, want)
303303
}
304+
305+
func TestAuthorization_Marshal(t *testing.T) {
306+
testJSONMarshal(t, &Authorization{}, "{}")
307+
308+
u := &Authorization{
309+
ID: Int64(1),
310+
URL: String("u"),
311+
Scopes: []Scope{"s"},
312+
Token: String("t"),
313+
TokenLastEight: String("tle"),
314+
HashedToken: String("ht"),
315+
App: &AuthorizationApp{
316+
URL: String("u"),
317+
Name: String("n"),
318+
ClientID: String("cid"),
319+
},
320+
Note: String("n"),
321+
NoteURL: String("nu"),
322+
UpdatedAt: &Timestamp{referenceTime},
323+
CreatedAt: &Timestamp{referenceTime},
324+
Fingerprint: String("f"),
325+
User: &User{
326+
Login: String("l"),
327+
ID: Int64(1),
328+
URL: String("u"),
329+
AvatarURL: String("a"),
330+
GravatarID: String("g"),
331+
Name: String("n"),
332+
Company: String("c"),
333+
Blog: String("b"),
334+
Location: String("l"),
335+
Email: String("e"),
336+
Hireable: Bool(true),
337+
Bio: String("b"),
338+
TwitterUsername: String("t"),
339+
PublicRepos: Int(1),
340+
Followers: Int(1),
341+
Following: Int(1),
342+
CreatedAt: &Timestamp{referenceTime},
343+
SuspendedAt: &Timestamp{referenceTime},
344+
},
345+
}
346+
347+
want := `{
348+
"id": 1,
349+
"url": "u",
350+
"scopes": ["s"],
351+
"token": "t",
352+
"token_last_eight": "tle",
353+
"hashed_token": "ht",
354+
"app": {
355+
"url": "u",
356+
"name": "n",
357+
"client_id": "cid"
358+
},
359+
"note": "n",
360+
"note_url": "nu",
361+
"updated_at": ` + referenceTimeStr + `,
362+
"created_at": ` + referenceTimeStr + `,
363+
"fingerprint": "f",
364+
"user": {
365+
"login": "l",
366+
"id": 1,
367+
"avatar_url": "a",
368+
"gravatar_id": "g",
369+
"name": "n",
370+
"company": "c",
371+
"blog": "b",
372+
"location": "l",
373+
"email": "e",
374+
"hireable": true,
375+
"bio": "b",
376+
"twitter_username": "t",
377+
"public_repos": 1,
378+
"followers": 1,
379+
"following": 1,
380+
"created_at": ` + referenceTimeStr + `,
381+
"suspended_at": ` + referenceTimeStr + `,
382+
"url": "u"
383+
}
384+
}`
385+
386+
testJSONMarshal(t, u, want)
387+
}

0 commit comments

Comments
 (0)