kopia lustrzana https://github.com/c9/core
fix download_test
rodzic
257a1970fd
commit
c30f5f3bb2
|
@ -4,14 +4,12 @@
|
|||
|
||||
|
||||
require("c9/inline-mocha")(module);
|
||||
if (typeof define === "undefined") {
|
||||
require("amd-loader");
|
||||
}
|
||||
require("amd-loader");
|
||||
|
||||
var assert = require("assert");
|
||||
var fs = require("fs");
|
||||
var tmp = require("tmp");
|
||||
var http = require("http");
|
||||
var mkdirp = require("mkdirp");
|
||||
var localfs = require("vfs-local");
|
||||
var download = require("./download");
|
||||
var urlParse = require('url').parse;
|
||||
|
@ -20,8 +18,9 @@ var execFile = require('child_process').execFile;
|
|||
describe(__filename, function() {
|
||||
this.timeout(4000);
|
||||
var base;
|
||||
var id = 0;
|
||||
|
||||
beforeEach(function(next) {
|
||||
before(function(next) {
|
||||
var that = this;
|
||||
var vfs = localfs({ root: "/" });
|
||||
download({}, {
|
||||
|
@ -58,14 +57,30 @@ describe(__filename, function() {
|
|||
});
|
||||
});
|
||||
|
||||
afterEach(function(next) {
|
||||
after(function(next) {
|
||||
this.server.close(next);
|
||||
});
|
||||
|
||||
before(cleanup);
|
||||
after(cleanup);
|
||||
|
||||
function cleanup(next) {
|
||||
execFile("rm", ["-rf", __dirname + "/_test"], function() {
|
||||
next();
|
||||
});
|
||||
}
|
||||
|
||||
function tmpDir(callback) {
|
||||
var path = __dirname + "/_test/" + id++;
|
||||
mkdirp(path, function(err) {
|
||||
callback(err, path);
|
||||
});
|
||||
}
|
||||
|
||||
describe("download", function() {
|
||||
|
||||
it("should download as tar", function(next) {
|
||||
tmp.dir({ unsafeCleanup: true }, function(err, path) {
|
||||
tmpDir(function(err, path) {
|
||||
assert.equal(err, null);
|
||||
var filename = "download.tar.gz";
|
||||
var file = fs.createWriteStream(path + "/" + filename);
|
||||
|
@ -90,7 +105,7 @@ describe(__filename, function() {
|
|||
});
|
||||
|
||||
it("should download sub directory as tar", function(next) {
|
||||
tmp.dir({ unsafeCleanup: true }, function(err, path) {
|
||||
tmpDir(function(err, path) {
|
||||
assert.equal(err, null);
|
||||
|
||||
var filename = "download.tar.gz";
|
||||
|
@ -113,7 +128,7 @@ describe(__filename, function() {
|
|||
});
|
||||
|
||||
it("should download without specifying a name", function(next) {
|
||||
tmp.dir({ unsafeCleanup: true }, function(err, path) {
|
||||
tmpDir(function(err, path) {
|
||||
assert.equal(err, null);
|
||||
|
||||
var filename = "download.tar.gz";
|
||||
|
@ -139,7 +154,7 @@ describe(__filename, function() {
|
|||
});
|
||||
|
||||
it("should download several files in same directory as tar", function(next) {
|
||||
tmp.dir({ unsafeCleanup: true }, function(err, path) {
|
||||
tmpDir(function(err, path) {
|
||||
assert.equal(err, null);
|
||||
|
||||
var filename = "download.tar.gz";
|
||||
|
@ -165,7 +180,7 @@ describe(__filename, function() {
|
|||
});
|
||||
|
||||
it("should download several files in different directories as tar", function(next) {
|
||||
tmp.dir({ unsafeCleanup: true }, function(err, path) {
|
||||
tmpDir(function(err, path) {
|
||||
assert.equal(err, null);
|
||||
|
||||
var filename = "download.tar.gz";
|
||||
|
@ -191,7 +206,7 @@ describe(__filename, function() {
|
|||
});
|
||||
|
||||
it("should download as zip", function(next) {
|
||||
tmp.dir({ unsafeCleanup: true }, function(err, path) {
|
||||
tmpDir(function(err, path) {
|
||||
assert.equal(err, null);
|
||||
var filename = "download.zip";
|
||||
var file = fs.createWriteStream(path + "/" + filename);
|
||||
|
@ -216,7 +231,7 @@ describe(__filename, function() {
|
|||
});
|
||||
|
||||
it("should download sub directory as zip", function(next) {
|
||||
tmp.dir({ unsafeCleanup: true }, function(err, path) {
|
||||
tmpDir(function(err, path) {
|
||||
assert.equal(err, null);
|
||||
|
||||
var filename = "download.zip";
|
||||
|
@ -239,7 +254,7 @@ describe(__filename, function() {
|
|||
});
|
||||
|
||||
it("should download several files in same directory as zip", function(next) {
|
||||
tmp.dir({ unsafeCleanup: true }, function(err, path) {
|
||||
tmpDir(function(err, path) {
|
||||
assert.equal(err, null);
|
||||
|
||||
var filename = "download.zip";
|
||||
|
@ -265,7 +280,7 @@ describe(__filename, function() {
|
|||
});
|
||||
|
||||
it("should download several files in different directories as zip", function(next) {
|
||||
tmp.dir({ unsafeCleanup: true }, function(err, path) {
|
||||
tmpDir(function(err, path) {
|
||||
assert.equal(err, null);
|
||||
|
||||
var filename = "download.zip";
|
||||
|
|
Ładowanie…
Reference in New Issue