test: add test for failed save in REPL

PR-URL: https://github.com/nodejs/io.js/pull/1818
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
pull/1927/head
Rich Trott 2015-05-27 19:20:28 -07:00
parent a3cc43d0a4
commit 8ea6844d26
1 changed files with 16 additions and 1 deletions

View File

@ -74,5 +74,20 @@ putIn.write = function(data) {
};
putIn.run(['.load ' + loadFile]);
// clear the REPL
putIn.run(['.clear']);
//TODO how do I do a failed .save test?
// 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');
// 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]);