You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rename-fail.js 671B

123456789101112131415161718192021222324252627282930
  1. 'use strict'
  2. var fs = require('graceful-fs')
  3. var path = require('path')
  4. var test = require('tap').test
  5. var rimraf = require('rimraf')
  6. var writeStream = require('../index.js')
  7. var target = path.resolve(__dirname, 'test-rename')
  8. test('rename fails', function (t) {
  9. t.plan(1)
  10. fs.rename = function (src, dest, cb) {
  11. cb(new Error('TEST BREAK'))
  12. }
  13. var stream = writeStream(target)
  14. var hadError = false
  15. stream.on('error', function (er) {
  16. hadError = true
  17. console.log('#', er)
  18. })
  19. stream.on('close', function () {
  20. t.is(hadError, true, 'error before close')
  21. })
  22. stream.end()
  23. })
  24. test('cleanup', function (t) {
  25. rimraf.sync(target)
  26. t.end()
  27. })