adapt test to new External api
This commit is contained in:
parent
19482586f9
commit
f313d50ef1
@ -1,18 +0,0 @@
|
||||
var path = require('path'),
|
||||
assert = require('assert'),
|
||||
mess = require('mess'),
|
||||
External = require('mess/external');
|
||||
|
||||
exports['test_unzip_remote'] = function() {
|
||||
var e = new External({
|
||||
data_dir: '.'
|
||||
});
|
||||
var remote = 'http://cascadenik-sampledata.s3.amazonaws.com/world_borders.zip';
|
||||
e.process(remote, function(err, result) {
|
||||
assert.eql(err, null);
|
||||
assert.eql(result[0], remote);
|
||||
assert.ok(result[1]);
|
||||
assert.eql(path.dirname(result[1]), e.pos(remote));
|
||||
}
|
||||
);
|
||||
};
|
41
test/zipfile.test.js
Normal file
41
test/zipfile.test.js
Normal file
@ -0,0 +1,41 @@
|
||||
var path = require('path'),
|
||||
assert = require('assert'),
|
||||
fs = require('fs'),
|
||||
External = require('mess/external');
|
||||
|
||||
exports['test_unzip_remote'] = function(beforeExit) {
|
||||
var tests = 0;
|
||||
var remote = 'http://cascadenik-sampledata.s3.amazonaws.com/world_borders.zip';
|
||||
var env = {
|
||||
data_dir: path.join(__dirname, 'zipfile')
|
||||
};
|
||||
new External(env, remote, function(err, result) {
|
||||
if (err) throw err;
|
||||
assert.ok(result instanceof External);
|
||||
assert.ok(/test\/zipfile\/95807c1308eb96804e2ed4fd9d89146f$/.test(result.path()));
|
||||
|
||||
fs.stat(result.path(), function(err, stats) {
|
||||
if (err) throw err;
|
||||
assert.ok(stats.isDirectory());
|
||||
tests++;
|
||||
});
|
||||
isFile(path.join(result.path(), 'world_borders.dbf'));
|
||||
isFile(path.join(result.path(), 'world_borders.prj'));
|
||||
isFile(path.join(result.path(), 'world_borders.shp'));
|
||||
isFile(path.join(result.path(), 'world_borders.shx'));
|
||||
|
||||
function isFile(file) {
|
||||
fs.stat(file, function(err, stats) {
|
||||
if (err) throw err;
|
||||
assert.ok(stats.isFile());
|
||||
tests++;
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
beforeExit(function() {
|
||||
assert.equal(tests, 5, 'Not all tests were executed.');
|
||||
});
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user