Skip to content

Commit 8ea6844

Browse files
committed
test: add test for failed save in REPL
PR-URL: #1818 Reviewed-By: Chris Dickinson <[email protected]>
1 parent a3cc43d commit 8ea6844

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

test/parallel/test-repl-.save.load.js

+16-1
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,20 @@ putIn.write = function(data) {
7474
};
7575
putIn.run(['.load ' + loadFile]);
7676

77+
// clear the REPL
78+
putIn.run(['.clear']);
79+
80+
// NUL (\0) is disallowed in filenames in UNIX-like operating systems and
81+
// Windows so we can use that to test failed saves
82+
const invalidFileName = join(common.tmpDir, '\0\0\0\0\0');
7783

78-
//TODO how do I do a failed .save test?
84+
// should not break
85+
putIn.write = function(data) {
86+
// make sure I get a failed to save message and not some other error
87+
assert.equal(data, 'Failed to save:' + invalidFileName + '\n');
88+
// reset to no-op
89+
putIn.write = function() {};
90+
};
91+
92+
// save it to a file
93+
putIn.run(['.save ' + invalidFileName]);

0 commit comments

Comments
 (0)