@@ -506,6 +506,11 @@ func TestJSON(t *testing.T) {
506506
507507 p := New ()
508508 p .Use (Gzip2 )
509+ p .Get ("/jsonstream" , func (w http.ResponseWriter , r * http.Request ) {
510+ if err := JSONStream (w , http .StatusOK , zombie {1 , "Patient Zero" }); err != nil {
511+ panic (err )
512+ }
513+ })
509514 p .Get ("/json" , func (w http.ResponseWriter , r * http.Request ) {
510515 if err := JSON (w , http .StatusOK , zombie {1 , "Patient Zero" }); err != nil {
511516 panic (err )
@@ -535,10 +540,18 @@ func TestJSON(t *testing.T) {
535540
536541 hf := p .Serve ()
537542
538- r , _ := http .NewRequest (http .MethodGet , "/json " , nil )
543+ r , _ := http .NewRequest (http .MethodGet , "/jsonstream " , nil )
539544 w := httptest .NewRecorder ()
540545 hf .ServeHTTP (w , r )
541546
547+ Equal (t , w .Code , http .StatusOK )
548+ Equal (t , w .Header ().Get (httpext .ContentType ), httpext .ApplicationJSON )
549+ Equal (t , w .Body .String (), jsonData + "\n " )
550+
551+ r , _ = http .NewRequest (http .MethodGet , "/json" , nil )
552+ w = httptest .NewRecorder ()
553+ hf .ServeHTTP (w , r )
554+
542555 Equal (t , w .Code , http .StatusOK )
543556 Equal (t , w .Header ().Get (httpext .ContentType ), httpext .ApplicationJSON )
544557 Equal (t , w .Body .String (), jsonData )
0 commit comments