Skip to content

Commit

Permalink
test: add test for failed save in REPL
Browse files Browse the repository at this point in the history
PR-URL: #1818
Reviewed-By: Chris Dickinson <[email protected]>
  • Loading branch information
Trott committed Jun 13, 2015
1 parent a3cc43d commit 8ea6844
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion test/parallel/test-repl-.save.load.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,20 @@ putIn.write = function(data) {
};
putIn.run(['.load ' + loadFile]);

// clear the REPL
putIn.run(['.clear']);

// NUL (\0) is disallowed in filenames in UNIX-like operating systems and
// Windows so we can use that to test failed saves
const invalidFileName = join(common.tmpDir, '\0\0\0\0\0');

//TODO how do I do a failed .save test?
// should not break
putIn.write = function(data) {
// make sure I get a failed to save message and not some other error
assert.equal(data, 'Failed to save:' + invalidFileName + '\n');
// reset to no-op
putIn.write = function() {};
};

// save it to a file
putIn.run(['.save ' + invalidFileName]);

0 comments on commit 8ea6844

Please sign in to comment.