Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adds some tests.

  • Loading branch information...
commit 524c43bfdc654d3f0a20e29765a09cf4ee266e72 1 parent ebf30cc
@SaltwaterC authored
View
7 tests/buffer.js
@@ -0,0 +1,7 @@
+var ftp = require('../');
+var assert = require('assert');
+
+ftp.get('ftp://127.0.0.1/foo.txt', function (err, res) {
+ assert.ifError(err);
+ assert.deepEqual(res, 'bar\n');
+});
View
1  tests/data/foo.txt
@@ -0,0 +1 @@
+bar
View
18 tests/file.js
@@ -0,0 +1,18 @@
+var ftp = require('../');
+var assert = require('assert');
+var fs = require('fs');
+var file = './foo.txt';
+
+ftp.get('ftp://127.0.0.1/foo.txt', file, function (err, res) {
+ assert.ifError(err);
+ fs.stat(file, function (err) {
+ assert.ifError(err);
+ fs.readFile(file, function (err, data) {
+ assert.ifError(err);
+ assert.deepEqual(data.toString(), 'bar\n');
+ fs.unlink(file, function (err) {
+ assert.ifError(err);
+ });
+ });
+ });
+});
View
26 tests/invalid-file-stream.js
@@ -0,0 +1,26 @@
+var ftp = require('../');
+var fs = require('fs');
+var p = require('path');
+var assert = require('assert');
+var path = p.resolve('foo.txt');
+
+try {
+ fs.statSync(path);
+ fs.unlinkSync(path);
+} catch (e) {}
+
+var fd = fs.openSync(path, 'w+');
+fs.closeSync(fd);
+fs.chmodSync(path, 0100);
+
+ftp.get('ftp://127.0.0.1/foo.txt', path, function (err, res) {
+ assert.ok(err instanceof Error);
+ assert.equal(err.errno, 13);
+ assert.deepEqual(err.code, 1);
+});
+
+process.on('exit', function () {
+ fs.unlink(path, function (err) {
+ assert.ifError(err);
+ });
+});
Please sign in to comment.
Something went wrong with that request. Please try again.