Skip to content

Commit 09633fa

Browse files
author
Alex Ivashchenko
committed
Made tests more local
1 parent 61adeff commit 09633fa

10 files changed

Lines changed: 41 additions & 9 deletions

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
language: node_js
22
node_js:
3-
- "0.8"
43
- "0.10"
54
- "0.12"
5+
- "iojs"

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"author": "Felix Geisendörfer <[email protected]> (http://debuggable.com/)",
33
"name": "form-data",
44
"description": "A module to create readable \"multipart/form-data\" streams. Can be used to submit forms and file uploads to other web applications.",
5-
"version": "0.2.0",
5+
"version": "1.0.0-rc0",
66
"repository": {
77
"type": "git",
88
"url": "git://github.com/felixge/node-form-data.git"
@@ -12,7 +12,7 @@
1212
"test": "node test/run.js"
1313
},
1414
"engines": {
15-
"node": ">= 0.8"
15+
"node": ">= 0.10"
1616
},
1717
"dependencies": {
1818
"async": "~0.9.0",

test/common.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ common.assert = require('assert');
1212
common.fake = require('fake');
1313

1414
common.port = 8432;
15+
16+
common.staticPort = 9432;

test/integration/test-http-response.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ var fs = require('fs');
88
var FormData = require(common.dir.lib + '/form_data');
99
var IncomingForm = require('formidable').IncomingForm;
1010

11-
var remoteFile = 'http://nodejs.org/images/logo.png';
11+
// static server prepared for all tests
12+
var remoteFile = 'http://localhost:'+common.staticPort+'/unicycle.jpg';
1213

1314
var FIELDS;
1415
var server;
@@ -22,6 +23,7 @@ var parsedUrl = parseUrl(remoteFile)
2223
}
2324
;
2425

26+
// request static file
2527
http.request(options, function(res) {
2628

2729
FIELDS = [
@@ -55,6 +57,7 @@ http.request(options, function(res) {
5557

5658
}).end();
5759

60+
// prepare form-receiving http server
5861
server = http.createServer(function(req, res) {
5962

6063
var form = new IncomingForm({uploadDir: common.dir.tmp});

test/integration/test-pipe.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var fs = require('fs');
88
var FormData = require(common.dir.lib + '/form_data');
99
var IncomingForm = require('formidable').IncomingForm;
1010

11-
var remoteFile = 'http://nodejs.org/images/logo.png';
11+
var remoteFile = 'http://localhost:'+common.staticPort+'/unicycle.jpg';
1212

1313
// wrap non simple values into function
1414
// just to deal with ReadStream "autostart"

test/integration/test-submit-custom-header.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var fs = require('fs');
88
var FormData = require(common.dir.lib + '/form_data');
99
var IncomingForm = require('formidable').IncomingForm;
1010

11-
var remoteFile = 'http://nodejs.org/images/logo.png';
11+
var remoteFile = 'http://localhost:'+common.staticPort+'/unicycle.jpg';
1212

1313
// wrap non simple values into function
1414
// just to deal with ReadStream "autostart"

test/integration/test-submit-custom.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var fs = require('fs');
88
var FormData = require(common.dir.lib + '/form_data');
99
var IncomingForm = require('formidable').IncomingForm;
1010

11-
var remoteFile = 'http://nodejs.org/images/logo.png';
11+
var remoteFile = 'http://localhost:'+common.staticPort+'/unicycle.jpg';
1212

1313
// wrap non simple values into function
1414
// just to deal with ReadStream "autostart"

test/integration/test-submit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var fs = require('fs');
88
var FormData = require(common.dir.lib + '/form_data');
99
var IncomingForm = require('formidable').IncomingForm;
1010

11-
var remoteFile = 'http://nodejs.org/images/logo.png';
11+
var remoteFile = 'http://localhost:'+common.staticPort+'/unicycle.jpg';
1212

1313
// wrap non simple values into function
1414
// just to deal with ReadStream "autostart"

test/run.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env node
2+
var static = require('./static');
23
var far = require('far').create();
34

45
if (process.env.verbose)
@@ -9,4 +10,8 @@ if (process.env.verbose)
910
far.add(__dirname);
1011
far.include(/test-.*\.js$/);
1112

12-
far.execute();
13+
// start static server for all tests
14+
static(function(staticServer)
15+
{
16+
far.execute();
17+
});

test/static.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// serves static files
2+
var http = require('http');
3+
var fs = require('fs');
4+
var path = require('path');
5+
var mime = require('mime-types');
6+
var common = require('./common');
7+
8+
module.exports = function(callback) {
9+
var server = http.createServer(function(req, res) {
10+
11+
var target = path.join(common.dir.fixture, req.url);
12+
var stat = fs.statSync(target);
13+
14+
res.writeHead(200, {
15+
'Content-Type': mime.lookup(target),
16+
'Content-Length': stat.size
17+
});
18+
19+
fs.createReadStream(target).pipe(res);
20+
});
21+
server.listen(common.staticPort, callback.bind(undefined, server));
22+
};

0 commit comments

Comments
 (0)