Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions test/stats-uid-gid.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ fs.statSync = function(path) {

var gfs = require('../graceful-fs.js')

test('graceful fs uses same stats constructor as fs', function (t) {
t.equal(gfs.Stats, fs.Stats, 'should reference the same constructor')

test('graceful fs includes correct uid & gid', function (t) {
if (!process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH) {
t.equal(fs.statSync(__filename).uid, -2)
t.equal(fs.statSync(__filename).gid, -2)
Expand All @@ -28,6 +26,16 @@ test('graceful fs uses same stats constructor as fs', function (t) {
t.end()
})

;(process.platform !== 'win32') && test('graceful fs includes valid uid & gid (async)', function (t) {
gfs.stat(__filename, function (er, stats) {
t.notOk(er)
t.ok(stats)
t.ok(stats.uid)
t.ok(stats.gid)
t.end()
})
})

test('does not throw when async stat fails', function (t) {
gfs.stat(__filename + ' this does not exist', function (er, stats) {
t.ok(er)
Expand Down
11 changes: 10 additions & 1 deletion test/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,17 @@ var gfs = require('../graceful-fs.js')
test('graceful fs uses same stats constructor as fs', function (t) {
t.equal(gfs.Stats, fs.Stats, 'should reference the same constructor')
t.ok(fs.statSync(__filename) instanceof fs.Stats,
'should be instance of fs.Stats')
'should be instance of fs.Stats (built-in fs.statSync call)')
t.ok(gfs.statSync(__filename) instanceof fs.Stats,
'should be instance of fs.Stats')
t.end()
})

test('graceful fs uses same stats constructor as fs (async)', function (t) {
gfs.stat(__filename, function (er, stats) {
t.notOk(er, 'should not receive an error result')
t.ok(stats, 'should receive a valid stats object')
t.ok(stats instanceof fs.Stats, 'should receive a valid stats object')
t.end()
})
})