@@ -15,6 +15,215 @@ import (
1515 "time"
1616)
1717
18+ func TestGist_marshall (t * testing.T ) {
19+ testJSONMarshal (t , & Gist {}, "{}" )
20+
21+ createdAt := time .Date (2010 , time .February , 10 , 10 , 10 , 0 , 0 , time .UTC )
22+ updatedAt := time .Date (2010 , time .February , 10 , 10 , 10 , 0 , 0 , time .UTC )
23+
24+ u := & Gist {
25+ ID : String ("i" ),
26+ Description : String ("description" ),
27+ Public : Bool (true ),
28+ Owner : & User {
29+ Login : String ("ll" ),
30+ ID : Int64 (123 ),
31+ AvatarURL : String ("a" ),
32+ GravatarID : String ("g" ),
33+ Name : String ("n" ),
34+ Company : String ("c" ),
35+ Blog : String ("b" ),
36+ Location : String ("l" ),
37+ Email : String ("e" ),
38+ Hireable : Bool (true ),
39+ PublicRepos : Int (1 ),
40+ Followers : Int (1 ),
41+ Following : Int (1 ),
42+ CreatedAt : & Timestamp {referenceTime },
43+ URL : String ("u" ),
44+ },
45+ Files : map [GistFilename ]GistFile {
46+ "gistfile.py" : {
47+ Size : Int (167 ),
48+ Filename : String ("gistfile.py" ),
49+ Language : String ("Python" ),
50+ Type : String ("application/x-python" ),
51+ RawURL : String ("raw-url" ),
52+ Content : String ("c" ),
53+ },
54+ },
55+ Comments : Int (1 ),
56+ HTMLURL : String ("html-url" ),
57+ GitPullURL : String ("gitpull-url" ),
58+ GitPushURL : String ("gitpush-url" ),
59+ CreatedAt : & createdAt ,
60+ UpdatedAt : & updatedAt ,
61+ NodeID : String ("node" ),
62+ }
63+
64+ want := `{
65+ "id": "i",
66+ "description": "description",
67+ "public": true,
68+ "owner": {
69+ "login": "ll",
70+ "id": 123,
71+ "avatar_url": "a",
72+ "gravatar_id": "g",
73+ "name": "n",
74+ "company": "c",
75+ "blog": "b",
76+ "location": "l",
77+ "email": "e",
78+ "hireable": true,
79+ "public_repos": 1,
80+ "followers": 1,
81+ "following": 1,
82+ "created_at": ` + referenceTimeStr + `,
83+ "url": "u"
84+ },
85+ "files": {
86+ "gistfile.py": {
87+ "size": 167,
88+ "filename": "gistfile.py",
89+ "language": "Python",
90+ "type": "application/x-python",
91+ "raw_url": "raw-url",
92+ "content": "c"
93+ }
94+ },
95+ "comments": 1,
96+ "html_url": "html-url",
97+ "git_pull_url": "gitpull-url",
98+ "git_push_url": "gitpush-url",
99+ "created_at": "2010-02-10T10:10:00Z",
100+ "updated_at": "2010-02-10T10:10:00Z",
101+ "node_id": "node"
102+ }`
103+
104+ testJSONMarshal (t , u , want )
105+ }
106+
107+ func TestGistCommit_marshall (t * testing.T ) {
108+ testJSONMarshal (t , & GistCommit {}, "{}" )
109+
110+ u := & GistCommit {
111+ URL : String ("u" ),
112+ Version : String ("v" ),
113+ User : & User {
114+ Login : String ("ll" ),
115+ ID : Int64 (123 ),
116+ AvatarURL : String ("a" ),
117+ GravatarID : String ("g" ),
118+ Name : String ("n" ),
119+ Company : String ("c" ),
120+ Blog : String ("b" ),
121+ Location : String ("l" ),
122+ Email : String ("e" ),
123+ Hireable : Bool (true ),
124+ PublicRepos : Int (1 ),
125+ Followers : Int (1 ),
126+ Following : Int (1 ),
127+ CreatedAt : & Timestamp {referenceTime },
128+ URL : String ("u" ),
129+ },
130+ ChangeStatus : & CommitStats {
131+ Additions : Int (1 ),
132+ Deletions : Int (1 ),
133+ Total : Int (2 ),
134+ },
135+ CommittedAt : & Timestamp {referenceTime },
136+ NodeID : String ("node" ),
137+ }
138+
139+ want := `{
140+ "url": "u",
141+ "version": "v",
142+ "user": {
143+ "login": "ll",
144+ "id": 123,
145+ "avatar_url": "a",
146+ "gravatar_id": "g",
147+ "name": "n",
148+ "company": "c",
149+ "blog": "b",
150+ "location": "l",
151+ "email": "e",
152+ "hireable": true,
153+ "public_repos": 1,
154+ "followers": 1,
155+ "following": 1,
156+ "created_at": ` + referenceTimeStr + `,
157+ "url": "u"
158+ },
159+ "change_status": {
160+ "additions": 1,
161+ "deletions": 1,
162+ "total": 2
163+ },
164+ "committed_at": ` + referenceTimeStr + `,
165+ "node_id": "node"
166+ }`
167+
168+ testJSONMarshal (t , u , want )
169+ }
170+
171+ func TestGistFork_marshall (t * testing.T ) {
172+ testJSONMarshal (t , & GistFork {}, "{}" )
173+
174+ u := & GistFork {
175+ URL : String ("u" ),
176+ User : & User {
177+ Login : String ("ll" ),
178+ ID : Int64 (123 ),
179+ AvatarURL : String ("a" ),
180+ GravatarID : String ("g" ),
181+ Name : String ("n" ),
182+ Company : String ("c" ),
183+ Blog : String ("b" ),
184+ Location : String ("l" ),
185+ Email : String ("e" ),
186+ Hireable : Bool (true ),
187+ PublicRepos : Int (1 ),
188+ Followers : Int (1 ),
189+ Following : Int (1 ),
190+ CreatedAt : & Timestamp {referenceTime },
191+ URL : String ("u" ),
192+ },
193+ ID : String ("id" ),
194+ CreatedAt : & Timestamp {referenceTime },
195+ UpdatedAt : & Timestamp {referenceTime },
196+ NodeID : String ("node" ),
197+ }
198+
199+ want := `{
200+ "url": "u",
201+ "user": {
202+ "login": "ll",
203+ "id": 123,
204+ "avatar_url": "a",
205+ "gravatar_id": "g",
206+ "name": "n",
207+ "company": "c",
208+ "blog": "b",
209+ "location": "l",
210+ "email": "e",
211+ "hireable": true,
212+ "public_repos": 1,
213+ "followers": 1,
214+ "following": 1,
215+ "created_at": ` + referenceTimeStr + `,
216+ "url": "u"
217+ },
218+ "id": "id",
219+ "created_at": ` + referenceTimeStr + `,
220+ "updated_at": ` + referenceTimeStr + `,
221+ "node_id": "node"
222+ }`
223+
224+ testJSONMarshal (t , u , want )
225+ }
226+
18227func TestGistsService_List_specifiedUser (t * testing.T ) {
19228 client , mux , _ , teardown := setup ()
20229 defer teardown ()
0 commit comments