Permalink
Browse files

Cleanup tests a bit.

Moved from ./auth to ./test/auth.json. Sorry for the one-time pain.
  • Loading branch information...
1 parent a172697 commit 10202001d7476bbc466621a570970ca279663828 @domenic domenic committed Oct 27, 2012
Showing with 27 additions and 38 deletions.
  1. +1 −4 .gitignore
  2. +1 −5 .npmignore
  3. +2 −2 Readme.md
  4. +21 −26 test/knox.test.js
  5. +2 −1 test/mocha.opts
View
@@ -1,6 +1,3 @@
-.DS_Store
-test.js
-/auth
+/test/auth.json
/node_modules/
/npm-debug.log
-.idea
View
@@ -1,12 +1,8 @@
# From .gitignore
-.DS_Store
-test.js
-/auth
-/node_modules/
/npm-debug.log
# Additions for .npmignore only
-/test
+/test/
/.npmignore
/History.md
/index.html
View
@@ -242,8 +242,8 @@ If you want to use a custom [HTTP agent][], you can specify this with the
## Running Tests
-To run the test suite you must first have an S3 account, and create
-a file named _./auth_, which contains your credentials as json, for example:
+To run the test suite you must first have an S3 account. Then create a file named
+_./test/auth.json_, which contains your credentials as JSON, for example:
```json
{
View
@@ -1,8 +1,3 @@
-
-/**
- * Module dependencies.
- */
-
var knox = require('..')
, signQuery = require('../lib/auth').signQuery
, fs = require('fs')
@@ -11,7 +6,7 @@ var knox = require('..')
, crypto = require('crypto');
try {
- var auth = JSON.parse(fs.readFileSync('auth', 'ascii'));
+ var auth = require("./auth.json");
var client = knox.createClient(auth);
auth.bucket = auth.bucketUsWest2;
// Without this we get a 307 redirect
@@ -23,12 +18,12 @@ try {
var clientUsWest2 = knox.createClient(auth);
} catch (err) {
console.error(err);
- console.error('The tests require ./auth to contain a JSON string with');
- console.error('key, secret, bucket and bucketUsWest2 in order to run tests.');
- console.error('Both bucket and bucketUsWest2 must exist and should not');
- console.error('contain anything you want to keep. bucket2 should be');
- console.error('created in the us-west-2 (Oregon) region, not the default');
- console.error('region.');
+ console.error('The tests require ./auth to contain a JSON string with key, ' +
+ 'secret, bucket, and bucketUsWest2 in order to run tests. ' +
+ 'Both bucket and bucketUsWest2 must exist and should not ' +
+ 'contain anything you want to keep. bucketUsWest2 should be ' +
+ 'created in the us-west-2 (Oregon) region, not the default ' +
+ 'region.');
process.exit(1);
}
@@ -53,7 +48,7 @@ module.exports = {
assert.throws(
function () {
- knox.createClient({ key: 'foo', secret: 'bar', bucket: 'BuCkEt' })
+ knox.createClient({ key: 'foo', secret: 'bar', bucket: 'BuCkEt' });
},
/bucket names must be all lower case/
);
@@ -171,7 +166,7 @@ module.exports = {
done();
});
req.end(buf);
- })
+ });
});
},
@@ -203,7 +198,7 @@ module.exports = {
if (100 !== res.statusCode) assert.equal(200, res.statusCode);
done();
});
- })
+ });
},
'test .putStream() with http stream': function(done){
@@ -297,26 +292,26 @@ module.exports = {
client.getFile('/test/user.json', function(err, res){
assert.ok(!err);
assert.equal(200, res.statusCode);
- assert.equal('application/json', res.headers['content-type'])
- assert.equal(13, res.headers['content-length'])
+ assert.equal('application/json', res.headers['content-type']);
+ assert.equal(13, res.headers['content-length']);
done();
});
},
'test .get()': function(done){
client.get('/test/user4.json').on('response', function(res){
assert.equal(200, res.statusCode);
- assert.equal('application/json', res.headers['content-type'])
- assert.equal(13, res.headers['content-length'])
+ assert.equal('application/json', res.headers['content-type']);
+ assert.equal(13, res.headers['content-length']);
done();
}).end();
},
'test .get() without leading slash': function(done){
client.get('buffer.txt').on('response', function(res){
assert.equal(200, res.statusCode);
- assert.equal('text/plain', res.headers['content-type'])
- assert.equal(17, res.headers['content-length'])
+ assert.equal('text/plain', res.headers['content-type']);
+ assert.equal(17, res.headers['content-length']);
done();
}).end();
},
@@ -334,8 +329,8 @@ module.exports = {
'test .head()': function(done){
client.head('/test/user.json').on('response', function(res){
assert.equal(200, res.statusCode);
- assert.equal('application/json', res.headers['content-type'])
- assert.equal(13, res.headers['content-length'])
+ assert.equal('application/json', res.headers['content-type']);
+ assert.equal(13, res.headers['content-length']);
done();
}).end();
},
@@ -344,8 +339,8 @@ module.exports = {
client.headFile('/test/user.json', function(err, res){
assert.ok(!err);
assert.equal(200, res.statusCode);
- assert.equal('application/json', res.headers['content-type'])
- assert.equal(13, res.headers['content-length'])
+ assert.equal('application/json', res.headers['content-type']);
+ assert.equal(13, res.headers['content-length']);
done();
});
},
@@ -450,7 +445,7 @@ module.exports = {
'test .signedUrl()': function(){
// Not much of a test, but hopefully will prevent regressions (see GH-81)
var date = new Date(2020, 1, 1);
- var timestamp = date.getTime() * .001;
+ var timestamp = date.getTime() * 0.001;
var signedUrl = client.signedUrl('/test/user.json', date);
var signature = signQuery({
secret: client.secret
View
@@ -1,3 +1,4 @@
--ui exports
---slow 500ms
+--slow 1000ms
+--timeout 5000ms
--reporter spec

0 comments on commit 1020200

Please sign in to comment.