@@ -2,8 +2,6 @@ package api_test
22
33import (
44 "bytes"
5- "encoding/json"
6- "io/ioutil"
75 "net/http"
86
97 "time"
@@ -41,13 +39,9 @@ var _ = Describe("/api/v2/journal", func() {
4139
4240 Expect (res .StatusCode ).To (Equal (200 ))
4341
44- responseJson , err := ioutil .ReadAll (res .Body )
45- Expect (err ).To (BeNil ())
46-
4742 var journalView v2.JournalView
4843
49- err = json .Unmarshal (responseJson , & journalView )
50- Expect (err ).To (BeNil ())
44+ functional_tests .UnmarshalFromResponse (res , & journalView )
5145
5246 Expect (journalView .Journal ).To (HaveLen (0 ))
5347 })
@@ -60,13 +54,9 @@ var _ = Describe("/api/v2/journal", func() {
6054
6155 Expect (res .StatusCode ).To (Equal (200 ))
6256
63- responseJson , err := ioutil .ReadAll (res .Body )
64- Expect (err ).To (BeNil ())
65-
6657 var journalView v2.JournalView
6758
68- err = json .Unmarshal (responseJson , & journalView )
69- Expect (err ).To (BeNil ())
59+ functional_tests .UnmarshalFromResponse (res , & journalView )
7060
7161 Expect (journalView .Journal ).To (HaveLen (1 ))
7262
@@ -96,13 +86,9 @@ var _ = Describe("/api/v2/journal", func() {
9686
9787 Expect (res .StatusCode ).To (Equal (200 ))
9888
99- responseJson , err := ioutil .ReadAll (res .Body )
100- Expect (err ).To (BeNil ())
101-
10289 var journalView v2.JournalView
10390
104- err = json .Unmarshal (responseJson , & journalView )
105- Expect (err ).To (BeNil ())
91+ functional_tests .UnmarshalFromResponse (res , & journalView )
10692
10793 Expect (journalView .Journal ).To (HaveLen (3 ))
10894
@@ -128,13 +114,9 @@ var _ = Describe("/api/v2/journal", func() {
128114
129115 Expect (res .StatusCode ).To (Equal (200 ))
130116
131- responseJson , err := ioutil .ReadAll (res .Body )
132- Expect (err ).To (BeNil ())
133-
134117 var journalView v2.JournalView
135118
136- err = json .Unmarshal (responseJson , & journalView )
137- Expect (err ).To (BeNil ())
119+ functional_tests .UnmarshalFromResponse (res , & journalView )
138120
139121 Expect (journalView .Journal ).To (HaveLen (2 ))
140122
@@ -166,13 +148,9 @@ var _ = Describe("/api/v2/journal", func() {
166148
167149 Expect (res .StatusCode ).To (Equal (http .StatusOK ))
168150
169- responseJson , err := ioutil .ReadAll (res .Body )
170- Expect (err ).To (BeNil ())
171-
172151 var journalView v2.JournalView
173152
174- err = json .Unmarshal (responseJson , & journalView )
175- Expect (err ).To (BeNil ())
153+ functional_tests .UnmarshalFromResponse (res , & journalView )
176154
177155 Expect (journalView .Journal ).To (HaveLen (1 ))
178156 Expect (* journalView .Journal [0 ].Request .Path ).To (Equal ("/first" ))
@@ -185,13 +163,9 @@ var _ = Describe("/api/v2/journal", func() {
185163
186164 Expect (res .StatusCode ).To (Equal (http .StatusBadRequest ))
187165
188- responseJson , err := ioutil .ReadAll (res .Body )
189- Expect (err ).To (BeNil ())
190-
191166 var errorView handlers.ErrorView
192167
193- err = json .Unmarshal (responseJson , & errorView )
194- Expect (err ).To (BeNil ())
168+ functional_tests .UnmarshalFromResponse (res , & errorView )
195169
196170 Expect (errorView .Error ).To (Equal ("Malformed JSON" ))
197171 })
@@ -203,13 +177,9 @@ var _ = Describe("/api/v2/journal", func() {
203177
204178 Expect (res .StatusCode ).To (Equal (http .StatusBadRequest ))
205179
206- responseJson , err := ioutil .ReadAll (res .Body )
207- Expect (err ).To (BeNil ())
208-
209180 var errorView handlers.ErrorView
210181
211- err = json .Unmarshal (responseJson , & errorView )
212- Expect (err ).To (BeNil ())
182+ functional_tests .UnmarshalFromResponse (res , & errorView )
213183
214184 Expect (errorView .Error ).To (Equal ("No \" request\" object in search parameters" ))
215185 })
@@ -228,13 +198,9 @@ var _ = Describe("/api/v2/journal", func() {
228198
229199 Expect (res .StatusCode ).To (Equal (200 ))
230200
231- responseJson , err := ioutil .ReadAll (res .Body )
232- Expect (err ).To (BeNil ())
233-
234201 var journalView v2.JournalView
235202
236- err = json .Unmarshal (responseJson , & journalView )
237- Expect (err ).To (BeNil ())
203+ functional_tests .UnmarshalFromResponse (res , & journalView )
238204
239205 Expect (journalView .Journal ).To (HaveLen (0 ))
240206 })
@@ -260,13 +226,9 @@ var _ = Describe("/api/v2/journal", func() {
260226
261227 Expect (res .StatusCode ).To (Equal (200 ))
262228
263- responseJson , err := ioutil .ReadAll (res .Body )
264- Expect (err ).To (BeNil ())
265-
266229 var journalView v2.JournalView
267230
268- err = json .Unmarshal (responseJson , & journalView )
269- Expect (err ).To (BeNil ())
231+ functional_tests .UnmarshalFromResponse (res , & journalView )
270232
271233 Expect (journalView .Journal ).To (HaveLen (0 ))
272234 })
@@ -279,13 +241,9 @@ var _ = Describe("/api/v2/journal", func() {
279241
280242 Expect (res .StatusCode ).To (Equal (200 ))
281243
282- responseJson , err := ioutil .ReadAll (res .Body )
283- Expect (err ).To (BeNil ())
284-
285244 var journalView v2.JournalView
286245
287- err = json .Unmarshal (responseJson , & journalView )
288- Expect (err ).To (BeNil ())
246+ functional_tests .UnmarshalFromResponse (res , & journalView )
289247
290248 Expect (journalView .Journal ).To (HaveLen (1 ))
291249
@@ -315,13 +273,9 @@ var _ = Describe("/api/v2/journal", func() {
315273
316274 Expect (res .StatusCode ).To (Equal (200 ))
317275
318- responseJson , err := ioutil .ReadAll (res .Body )
319- Expect (err ).To (BeNil ())
320-
321276 var journalView v2.JournalView
322277
323- err = json .Unmarshal (responseJson , & journalView )
324- Expect (err ).To (BeNil ())
278+ functional_tests .UnmarshalFromResponse (res , & journalView )
325279
326280 Expect (journalView .Journal ).To (HaveLen (3 ))
327281
@@ -356,13 +310,9 @@ var _ = Describe("/api/v2/journal", func() {
356310
357311 Expect (res .StatusCode ).To (Equal (http .StatusOK ))
358312
359- responseJson , err := ioutil .ReadAll (res .Body )
360- Expect (err ).To (BeNil ())
361-
362313 var journalView v2.JournalView
363314
364- err = json .Unmarshal (responseJson , & journalView )
365- Expect (err ).To (BeNil ())
315+ functional_tests .UnmarshalFromResponse (res , & journalView )
366316
367317 Expect (journalView .Journal ).To (HaveLen (1 ))
368318 Expect (* journalView .Journal [0 ].Request .Path ).To (Equal ("/first" ))
@@ -375,13 +325,9 @@ var _ = Describe("/api/v2/journal", func() {
375325
376326 Expect (res .StatusCode ).To (Equal (http .StatusBadRequest ))
377327
378- responseJson , err := ioutil .ReadAll (res .Body )
379- Expect (err ).To (BeNil ())
380-
381328 var errorView handlers.ErrorView
382329
383- err = json .Unmarshal (responseJson , & errorView )
384- Expect (err ).To (BeNil ())
330+ functional_tests .UnmarshalFromResponse (res , & errorView )
385331
386332 Expect (errorView .Error ).To (Equal ("Malformed JSON" ))
387333 })
@@ -393,13 +339,9 @@ var _ = Describe("/api/v2/journal", func() {
393339
394340 Expect (res .StatusCode ).To (Equal (http .StatusBadRequest ))
395341
396- responseJson , err := ioutil .ReadAll (res .Body )
397- Expect (err ).To (BeNil ())
398-
399342 var errorView handlers.ErrorView
400343
401- err = json .Unmarshal (responseJson , & errorView )
402- Expect (err ).To (BeNil ())
344+ functional_tests .UnmarshalFromResponse (res , & errorView )
403345
404346 Expect (errorView .Error ).To (Equal ("No \" request\" object in search parameters" ))
405347 })
@@ -418,13 +360,9 @@ var _ = Describe("/api/v2/journal", func() {
418360
419361 Expect (res .StatusCode ).To (Equal (200 ))
420362
421- responseJson , err := ioutil .ReadAll (res .Body )
422- Expect (err ).To (BeNil ())
423-
424363 var journalView v2.JournalView
425364
426- err = json .Unmarshal (responseJson , & journalView )
427- Expect (err ).To (BeNil ())
365+ functional_tests .UnmarshalFromResponse (res , & journalView )
428366
429367 Expect (journalView .Journal ).To (HaveLen (0 ))
430368 })
@@ -451,13 +389,9 @@ var _ = Describe("/api/v2/journal", func() {
451389
452390 Expect (res .StatusCode ).To (Equal (http .StatusInternalServerError ))
453391
454- responseJson , err := ioutil .ReadAll (res .Body )
455- Expect (err ).To (BeNil ())
456-
457392 var errorView handlers.ErrorView
458393
459- err = json .Unmarshal (responseJson , & errorView )
460- Expect (err ).To (BeNil ())
394+ functional_tests .UnmarshalFromResponse (res , & errorView )
461395
462396 Expect (errorView .Error ).To (Equal ("Journal disabled" ))
463397 })
@@ -481,13 +415,9 @@ var _ = Describe("/api/v2/journal", func() {
481415
482416 Expect (res .StatusCode ).To (Equal (http .StatusInternalServerError ))
483417
484- responseJson , err := ioutil .ReadAll (res .Body )
485- Expect (err ).To (BeNil ())
486-
487418 var errorView handlers.ErrorView
488419
489- err = json .Unmarshal (responseJson , & errorView )
490- Expect (err ).To (BeNil ())
420+ functional_tests .UnmarshalFromResponse (res , & errorView )
491421
492422 Expect (errorView .Error ).To (Equal ("Journal disabled" ))
493423 })
@@ -501,13 +431,9 @@ var _ = Describe("/api/v2/journal", func() {
501431
502432 Expect (res .StatusCode ).To (Equal (http .StatusInternalServerError ))
503433
504- responseJson , err := ioutil .ReadAll (res .Body )
505- Expect (err ).To (BeNil ())
506-
507434 var errorView handlers.ErrorView
508435
509- err = json .Unmarshal (responseJson , & errorView )
510- Expect (err ).To (BeNil ())
436+ functional_tests .UnmarshalFromResponse (res , & errorView )
511437
512438 Expect (errorView .Error ).To (Equal ("Journal disabled" ))
513439 })
@@ -537,13 +463,9 @@ var _ = Describe("/api/v2/journal", func() {
537463
538464 Expect (res .StatusCode ).To (Equal (200 ))
539465
540- responseJson , err := ioutil .ReadAll (res .Body )
541- Expect (err ).To (BeNil ())
542-
543466 var journalView v2.JournalView
544467
545- err = json .Unmarshal (responseJson , & journalView )
546- Expect (err ).To (BeNil ())
468+ functional_tests .UnmarshalFromResponse (res , & journalView )
547469
548470 Expect (journalView .Journal ).To (HaveLen (10 ))
549471 })
0 commit comments