1 var test = require('tap').test
2 var fs = require('../graceful-fs.js')
4 test('graceful fs is not fs', function (t) {
5 t.notEqual(fs, require('fs'))
9 test('open an existing file works', function (t) {
10 var start = fs._curOpen
11 var fd = fs.openSync(__filename, 'r')
12 t.equal(fs._curOpen, start + 1)
14 t.equal(fs._curOpen, start)
15 fs.open(__filename, 'r', function (er, fd) {
17 t.equal(fs._curOpen, start + 1)
18 fs.close(fd, function (er) {
20 t.equal(fs._curOpen, start)
26 test('open a non-existing file throws', function (t) {
27 var start = fs._curOpen
30 var fd = fs.openSync('this file does not exist', 'r')
34 t.ok(er, 'should throw')
35 t.notOk(fd, 'should not get an fd')
36 t.equal(er.code, 'ENOENT')
37 t.equal(fs._curOpen, start)
39 fs.open('neither does this file', 'r', function (er, fd) {
40 t.ok(er, 'should throw')
41 t.notOk(fd, 'should not get an fd')
42 t.equal(er.code, 'ENOENT')
43 t.equal(fs._curOpen, start)