HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux wordpress-ubuntu-s-2vcpu-4gb-fra1-01 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/tana/frontend/node_modules/globule/node_modules/graceful-fs/test/open.js
var test = require('tap').test
var fs = require('../graceful-fs.js')

test('graceful fs is not fs', function (t) {
  t.notEqual(fs, require('fs'))
  t.end()
})

test('open an existing file works', function (t) {
  var start = fs._curOpen
  var fd = fs.openSync(__filename, 'r')
  t.equal(fs._curOpen, start + 1)
  fs.closeSync(fd)
  t.equal(fs._curOpen, start)
  fs.open(__filename, 'r', function (er, fd) {
    if (er) throw er
    t.equal(fs._curOpen, start + 1)
    fs.close(fd, function (er) {
      if (er) throw er
      t.equal(fs._curOpen, start)
      t.end()
    })
  })
})

test('open a non-existing file throws', function (t) {
  var start = fs._curOpen
  var er
  try {
    var fd = fs.openSync('this file does not exist', 'r')
  } catch (x) {
    er = x
  }
  t.ok(er, 'should throw')
  t.notOk(fd, 'should not get an fd')
  t.equal(er.code, 'ENOENT')
  t.equal(fs._curOpen, start)

  fs.open('neither does this file', 'r', function (er, fd) {
    t.ok(er, 'should throw')
    t.notOk(fd, 'should not get an fd')
    t.equal(er.code, 'ENOENT')
    t.equal(fs._curOpen, start)
    t.end()
  })
})