added a test: open a new file for writing, and set a mode for that file
This commit is contained in:
parent
f3a7170133
commit
30752c9109
|
@ -1629,7 +1629,7 @@ function open(fs, context, path, flags, mode, callback) {
|
|||
*/
|
||||
if (arguments.length == 5){
|
||||
callback = arguments[arguments.length - 1];
|
||||
mode = 0o666;
|
||||
mode = 0o644;
|
||||
}
|
||||
else {
|
||||
//need to test this validateAndMakeMode
|
||||
|
@ -1928,8 +1928,8 @@ function validateAndMaskMode(value, def, callback) {
|
|||
callback = def;
|
||||
def = undefined;
|
||||
}
|
||||
|
||||
if (isUint32(value)) {
|
||||
let newMode = value & FULL_READ_WRITE_EXEC_PERMISSIONS;
|
||||
return value & FULL_READ_WRITE_EXEC_PERMISSIONS;
|
||||
}
|
||||
|
||||
|
|
|
@ -106,6 +106,24 @@ describe('fs.open', function() {
|
|||
});
|
||||
});
|
||||
|
||||
|
||||
it('should create a new file, when flagged for write, and set the mode to the passed value', function(done) {
|
||||
|
||||
var fs = util.fs();
|
||||
fs.open('/myfile', 'w', 0o777, function(error) {
|
||||
if(error) throw error;
|
||||
|
||||
fs.stat('/myfile', function(error, result) {
|
||||
expect(error).not.to.exist;
|
||||
expect(result).to.exist;
|
||||
expect(result.mode).to.exist;
|
||||
expect(result.mode & 0o777).to.equal(0o777);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* This test is currently correct per our code, but incorrect according to the spec.
|
||||
* When we fix https://github.com/filerjs/filer/issues/314 we'll have to update this.
|
||||
|
|
Loading…
Reference in New Issue