@@ -5,6 +5,7 @@ var restify = require('restify');
55var support = require ( '../support' ) ;
66var http = support . http ;
77var responder = main . server . responder ;
8+ var file_to_download = path . join ( __dirname , '../support/fixtures' , 'fake_data.js' ) ;
89
910var methods = {
1011 get_restify_error : function ( req , res , next ) {
@@ -38,12 +39,12 @@ var methods = {
3839 } ,
3940
4041 download_content : function ( req , res , next ) {
41- var stats = fs . statSync ( __filename ) ;
42+ var stats = fs . statSync ( file_to_download ) ;
4243
4344 var args = {
4445 filename : 'responder.functional.js' ,
4546 contentType : 'application/javascript' ,
46- stream : fs . createReadStream ( __filename ) ,
47+ stream : fs . createReadStream ( file_to_download ) ,
4748 contentLength : stats . size
4849 } ;
4950
@@ -198,7 +199,8 @@ describe("functional - server/responder.js", function () {
198199 req . on ( 'result' , function ( err , res ) {
199200 assert . ifError ( err ) ; // HTTP status code >= 400;
200201
201- filename = path . join ( __dirname , '../../tmp' , 'test.js' ) ;
202+ filename = path . join ( __dirname , '../support/tmp' , 'downloaded_file.js' ) ;
203+ var expected_file_size = fs . statSync ( file_to_download ) . size ;
202204 stream = fs . createWriteStream ( filename ) ;
203205
204206 res . on ( 'data' , function ( chunk ) {
@@ -208,12 +210,12 @@ describe("functional - server/responder.js", function () {
208210 res . on ( 'end' , function ( ) {
209211 stream . end ( function ( ) {
210212 assert . equal ( res . headers [ 'content-type' ] , 'application/javascript' ) ;
211- assert . equal ( res . headers [ 'content-length' ] , 7948 ) ;
213+ assert . equal ( res . headers [ 'content-length' ] , expected_file_size ) ;
212214 assert . equal ( res . headers [ 'content-disposition' ] , 'attachment; filename=responder.functional.js' ) ;
213215 assert . equal ( res . statusCode , 200 ) ;
214216
215217 stats = fs . statSync ( filename ) ;
216- assert . equal ( stats . size , 7948 ) ;
218+ assert . equal ( stats . size , expected_file_size ) ;
217219
218220 done ( ) ;
219221 } ) ;
0 commit comments