Skip to content

Commit

Permalink
error testing added
Browse files Browse the repository at this point in the history
  • Loading branch information
raszi committed Sep 5, 2011
1 parent 711af99 commit 311531a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/dir-test.js
Expand Up @@ -27,6 +27,7 @@ vows.describe('Directory creation').addBatch({
tmp.dir(this.callback);
},

'should not return with error': assert.isNull,
'should be a directory': _testDir(040700),
'should have the default prefix': Test.testPrefix('tmp-')
},
Expand All @@ -36,6 +37,7 @@ vows.describe('Directory creation').addBatch({
tmp.dir({ prefix: 'something' }, this.callback);
},

'should not return with error': assert.isNull,
'should be a directory': _testDir(040700),
'should have the provided prefix': Test.testPrefix('something')
},
Expand All @@ -45,6 +47,7 @@ vows.describe('Directory creation').addBatch({
tmp.dir({ postfix: '.txt' }, this.callback);
},

'should not return with error': assert.isNull,
'should be a directory': _testDir(040700),
'should have the provided postfix': Test.testPostfix('.txt')

Expand All @@ -55,6 +58,7 @@ vows.describe('Directory creation').addBatch({
tmp.dir({ template: tmp.tmpdir.concat('clike-XXXXXX-postfix') }, this.callback);
},

'should not return with error': assert.isNull,
'should be a file': _testDir(040700),
'should have the provided prefix': Test.testPrefix('clike-'),
'should have the provided postfix': Test.testPostfix('-postfix')
Expand All @@ -65,6 +69,7 @@ vows.describe('Directory creation').addBatch({
tmp.dir({ prefix: 'foo', postfix: 'bar', mode: 0750 }, this.callback);
},

'should not return with error': assert.isNull,
'should be a directory': _testDir(040750),
'should have the provided prefix': Test.testPrefix('foo'),
'should have the provided postfix': Test.testPostfix('bar')
Expand All @@ -75,6 +80,7 @@ vows.describe('Directory creation').addBatch({
tmp.dir({ prefix: 'complicated', postfix: 'options', mode: 0755 }, this.callback);
},

'should not return with error': assert.isNull,
'should be a directory': _testDir(040755),
'should have the provided prefix': Test.testPrefix('complicated'),
'should have the provided postfix': Test.testPostfix('options')
Expand All @@ -95,6 +101,7 @@ vows.describe('Directory creation').addBatch({
Test.testKeep('dir', '1', this.callback);
},

'should not return with error': assert.isNull,
'should be a dir': function(err, name) {
_testDir(040700)(err, name);
fs.rmdirSync(name);
Expand All @@ -106,6 +113,7 @@ vows.describe('Directory creation').addBatch({
Test.testKeep('dir', '0', this.callback);
},

'should not return with error': assert.isNull,
'should not exist': function(err, name) {
assert.ok(!path.existsSync(name), "Directory should be removed");
}
Expand Down
8 changes: 8 additions & 0 deletions test/file-test.js
Expand Up @@ -37,6 +37,7 @@ vows.describe('File creation').addBatch({
tmp.file(this.callback);
},

'should not return with error': assert.isNull,
'should be a file': _testFile(0100600, true),
'should have the default prefix': Test.testPrefix('tmp-'),
'should have the default postfix': Test.testPostfix('.tmp')
Expand All @@ -47,6 +48,7 @@ vows.describe('File creation').addBatch({
tmp.file({ prefix: 'something' }, this.callback);
},

'should not return with error': assert.isNull,
'should be a file': _testFile(0100600, true),
'should have the provided prefix': Test.testPrefix('something')
},
Expand All @@ -56,6 +58,7 @@ vows.describe('File creation').addBatch({
tmp.file({ postfix: '.txt' }, this.callback);
},

'should not return with error': assert.isNull,
'should be a file': _testFile(0100600, true),
'should have the provided postfix': Test.testPostfix('.txt')

Expand All @@ -66,6 +69,7 @@ vows.describe('File creation').addBatch({
tmp.file({ template: tmp.tmpdir.concat('clike-XXXXXX-postfix') }, this.callback);
},

'should not return with error': assert.isNull,
'should be a file': _testFile(0100600, true),
'should have the provided prefix': Test.testPrefix('clike-'),
'should have the provided postfix': Test.testPostfix('-postfix')
Expand All @@ -76,6 +80,7 @@ vows.describe('File creation').addBatch({
tmp.file({ prefix: 'foo', postfix: 'bar', mode: 0640 }, this.callback);
},

'should not return with error': assert.isNull,
'should be a file': _testFile(0100640, true),
'should have the provided prefix': Test.testPrefix('foo'),
'should have the provided postfix': Test.testPostfix('bar')
Expand All @@ -86,6 +91,7 @@ vows.describe('File creation').addBatch({
tmp.file({ prefix: 'complicated', postfix: 'options', mode: 0644 }, this.callback);
},

'should not return with error': assert.isNull,
'should be a file': _testFile(0100644, true),
'should have the provided prefix': Test.testPrefix('complicated'),
'should have the provided postfix': Test.testPostfix('options')
Expand All @@ -106,6 +112,7 @@ vows.describe('File creation').addBatch({
Test.testKeep('file', '1', this.callback);
},

'should not return with error': assert.isNull,
'should be a file': function(err, name) {
_testFile(0100600, false)(err, name, null);
fs.unlinkSync(name);
Expand All @@ -117,6 +124,7 @@ vows.describe('File creation').addBatch({
Test.testKeep('file', '0', this.callback);
},

'should not return with error': assert.isNull,
'should not exist': function(err, name) {
assert.ok(!path.existsSync(name), "File should be removed");
}
Expand Down

0 comments on commit 311531a

Please sign in to comment.