Skip to content

Commit a104b96

Browse files
committed
moving test download file to support/tmp
1 parent 2a684ec commit a104b96

File tree

4 files changed

+42
-5
lines changed

4 files changed

+42
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ node_modules
22
coverage
33
log/*.log
44
tmp/*.*
5+
test/support/tmp/*.js

test/server/responder.functional.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var restify = require('restify');
55
var support = require('../support');
66
var http = support.http;
77
var responder = main.server.responder;
8+
var file_to_download = path.join(__dirname, '../support/fixtures', 'fake_data.js');
89

910
var 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
});

test/support/fixtures/fake_data.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
var blah = 'foo';
2+
blah = 'foo';
3+
blah = 'foo';
4+
blah = 'foo';
5+
blah = 'foo';
6+
blah = 'foo';
7+
blah = 'foo';
8+
blah = 'foo';
9+
blah = 'foo';
10+
blah = 'foo';
11+
blah = 'foo';
12+
blah = 'foo';
13+
blah = 'foo';
14+
blah = 'foo';
15+
blah = 'foo';
16+
blah = 'foo';
17+
blah = 'foo';
18+
blah = 'foo';
19+
blah = 'foo';
20+
blah = 'foo';
21+
blah = 'foo';
22+
blah = 'foo';
23+
blah = 'foo';
24+
blah = 'foo';
25+
blah = 'foo';
26+
blah = 'foo';
27+
blah = 'foo';
28+
blah = 'foo';
29+
blah = 'foo';
30+
blah = 'foo';
31+
blah = 'foo';
32+
blah = 'foo';
33+
blah = 'foo';
34+
blah = 'foo';

test/support/tmp/placeholder.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)