Comparing version 0.1.9 to 0.1.11
11
index.js
var fs = require("fs"); | ||
var async = require("async"); | ||
var utils = require(__dirname + "/utils"); | ||
var join = require("path").join; | ||
var relative = require("path").relative; | ||
@@ -73,2 +75,3 @@ var Client = module.exports = function (config) { | ||
}; | ||
Client.prototype.putBuffer = function(buffer, to, headers, callback) { | ||
@@ -87,2 +90,3 @@ var self = this; | ||
}; | ||
Client.prototype.deleteFile = function(file, callback) { | ||
@@ -95,2 +99,3 @@ var self = this; | ||
}; | ||
Client.prototype.copyFile = function(from, to, callback) { | ||
@@ -122,2 +127,3 @@ var self = this; | ||
}; | ||
Client.prototype.list = function (options, cb) { | ||
@@ -143,3 +149,4 @@ var self = this; | ||
walker.on("file", function (root, stat, next) { | ||
files.push({Key: options.prefix + stat.name}); | ||
var directory = relative(self.config.bucket, root); | ||
files.push({Key: join(directory, stat.name)}); | ||
next(); | ||
@@ -158,3 +165,1 @@ }); | ||
}; | ||
{ | ||
"name": "faux-knox", | ||
"version": "0.1.9", | ||
"version": "0.1.11", | ||
"description": "Mock requests to knox module using file system", | ||
@@ -24,9 +24,9 @@ "main": "index.js", | ||
"devDependencies": { | ||
"mocha": "~1.12.0", | ||
"should": "~1.2.2" | ||
"mocha": "~1.21.3", | ||
"should": "~4.0.4" | ||
}, | ||
"dependencies": { | ||
"underscore": "~1.5.1", | ||
"async": "~0.2.9", | ||
"mkdirp": "~0.3.5", | ||
"underscore": "~1.6.0", | ||
"async": "~0.9.0", | ||
"mkdirp": "~0.5.0", | ||
"rimraf": "~2.2.1", | ||
@@ -33,0 +33,0 @@ "walk": "^2.3.1" |
@@ -1,2 +0,2 @@ | ||
faux-knox-2 | ||
faux-knox | ||
========= | ||
@@ -34,2 +34,11 @@ | ||
#####list | ||
```js | ||
function(options, callback) | ||
callback(err, list) | ||
``` | ||
`list` is an object with a Contents array containing the returned files. | ||
#####getFile | ||
@@ -88,2 +97,1 @@ | ||
functionality | ||
50
test.js
@@ -12,3 +12,3 @@ var should = require("should"); | ||
it("should have a createClient function", function() { | ||
knox.should.have.property("createClient").be.a("function"); | ||
knox.should.have.property("createClient").and.be.a.Function; | ||
}); | ||
@@ -18,3 +18,3 @@ it("should support methods", function(done) { | ||
function checker(method, callback) { | ||
client.should.have.property(method).be.a("function"); | ||
client.should.have.property(method).and.be.a.Function; | ||
callback(); | ||
@@ -28,3 +28,3 @@ } | ||
client.getFile("path/to/test.json", null, function(err, cres) { | ||
cres.should.have.property("headers").be.a("object"); | ||
cres.should.have.property("headers").and.be.a.Object; | ||
cres.should.have.property("statusCode", 200); | ||
@@ -59,3 +59,3 @@ function getBuffer(callback) { | ||
client.putFile("./test_files/put/fort_knox_tank.jpg", "from/fort/knox/super_tank.jpg", function(err, res) { | ||
res.should.have.property("headers").be.a("object"); | ||
res.should.have.property("headers").and.be.a.Object; | ||
res.should.have.property("statusCode", 201); | ||
@@ -70,3 +70,3 @@ fs.exists("./test_files/from/fort/knox/super_tank.jpg", function(existy) { | ||
client.putFile("./test_files/put/fort_knox_tank.jpg", "from/fort/knox/super_tank_headers.jpg", {header: "value"}, function(err, res) { | ||
res.should.have.property("headers").be.a("object"); | ||
res.should.have.property("headers").and.be.a.Object; | ||
res.should.have.property("statusCode", 201); | ||
@@ -91,3 +91,3 @@ fs.exists("./test_files/from/fort/knox/super_tank_headers.jpg", function(existy) { | ||
client.putBuffer(buff, "from/buffer/land/dev/null.text", {"Content-Type":"text/plain"}, function(err, res) { | ||
res.should.have.property("headers").be.a("object"); | ||
res.should.have.property("headers").and.be.a.Object; | ||
res.should.have.property("statusCode", 201); | ||
@@ -111,3 +111,3 @@ done(); | ||
client.deleteFile("to/a/new/path/here/tank.jpg", function(err, res) { | ||
res.should.have.property("headers").be.a("object"); | ||
res.should.have.property("headers").and.be.a.Object; | ||
res.should.have.property("statusCode", 204); | ||
@@ -120,3 +120,3 @@ fileExists(false, done); | ||
client.deleteFile("not/a/real/path.js", function(err, res) { | ||
res.should.have.property("headers").be.a("object"); | ||
res.should.have.property("headers").and.be.a.Object; | ||
res.should.have.property("statusCode", 404); | ||
@@ -140,3 +140,3 @@ done(); | ||
client.copyFile("to/a/new/path/here/tank.jpg", "to/a/new/path/here/tankCopy.jpg", function(err, res) { | ||
res.should.have.property("headers").be.a("object"); | ||
res.should.have.property("headers").and.be.a.Object; | ||
res.should.have.property("statusCode", 201); | ||
@@ -151,2 +151,34 @@ fileExists(true, done); | ||
}); | ||
describe("list", function() { | ||
it("should list", function (done) { | ||
var opts = {prefix: "list/"}; | ||
client.list(opts, function (err, page) { | ||
if (err) return done(err); | ||
page.Contents.should.eql([ | ||
{Key: "list/one"}, {Key: "list/two"} | ||
]); | ||
done(); | ||
}); | ||
}); | ||
it("should join paths correctly", function (done) { | ||
var opts = {prefix: "list"}; | ||
client.list(opts, function (err, page) { | ||
if (err) return done(err); | ||
page.Contents.should.eql([ | ||
{Key: "list/one"}, {Key: "list/two"} | ||
]); | ||
done(); | ||
}); | ||
}); | ||
it("should list recursively", function (done) { | ||
var opts = {prefix: "list_nested"}; | ||
client.list(opts, function (err, page) { | ||
if (err) return done(err); | ||
page.Contents.should.eql([ | ||
{Key: "list_nested/level/one"}, {Key: "list_nested/level/two"} | ||
]); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -12,2 +12,2 @@ var _ = require('underscore'); | ||
}); | ||
} | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
13055
320
96
1
+ Addedasync@0.9.2(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addedunderscore@1.6.0(transitive)
- Removedasync@0.2.10(transitive)
- Removedmkdirp@0.3.5(transitive)
- Removedunderscore@1.5.2(transitive)
Updatedasync@~0.9.0
Updatedmkdirp@~0.5.0
Updatedunderscore@~1.6.0