test: fs.realpath() should not call its callback twice
authorBen Noordhuis <info@bnoordhuis.nl>
Tue, 8 Nov 2011 12:03:25 +0000 (13:03 +0100)
committerBen Noordhuis <info@bnoordhuis.nl>
Tue, 8 Nov 2011 12:03:29 +0000 (13:03 +0100)
Test case for #2045.

test/simple/test-fs-realpath.js

index 27ac0b8..b2c8e9b 100644 (file)
@@ -79,6 +79,19 @@ function bashRealpath(path, callback) {
 }
 
 // sub-tests:
+function test_simple_error_callback() {
+  var ncalls = 0;
+
+  fs.realpath('/this/path/does/not/exist', function(err, s) {
+    assert(err);
+    assert(!s);
+    ncalls++;
+  });
+
+  process.on('exit', function() {
+    assert.equal(ncalls, 1);
+  });
+}
 
 function test_simple_relative_symlink(callback) {
   console.log('test_simple_relative_symlink');
@@ -415,6 +428,7 @@ function test_lying_cache_liar(cb) {
 // ----------------------------------------------------------------------------
 
 var tests = [
+  test_simple_error_callback,
   test_simple_relative_symlink,
   test_simple_absolute_symlink,
   test_deep_relative_file_symlink,