Skip to content

Commit

Permalink
Merge pull request #40 from Michaelpalacce/develop
Browse files Browse the repository at this point in the history
[develop] v28.2.2
  • Loading branch information
Michaelpalacce committed Aug 8, 2020
2 parents ff9a360 + 9960912 commit 2e7bbcf
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 2 deletions.
3 changes: 3 additions & 0 deletions UPDATELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
28.2.2
- setUpPersistence with DataServerMap now works correctly without having to delete the file.

28.2.1
- X-Powered-By added when using EventRequest.send()

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"test": "nyc --reporter=lcov --reporter=text-summary node test.js --debug",
"deploy": "npm run test && npm publish"
},
"version": "28.2.1",
"version": "28.2.2",
"devDependencies": {
"nyc": "^15.1.0"
}
Expand Down
2 changes: 1 addition & 1 deletion server/components/caching/data_server_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class DataServerMap extends DataServer
}
else
{
fs.writeFileSync( this.persistPath, JSON.stringify( this.useBigMap ? new BigMap() : new Map() ) );
fs.writeFileSync( this.persistPath, JSON.stringify( this.useBigMap ? new BigMap() : new Map(), DataServerMap.replacer ) );
}
}

Expand Down
40 changes: 40 additions & 0 deletions tests/server/components/caching/data_server_map_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,46 @@ test({
}
});

test({
message : 'DataServerMap._setUpPersistence.works.correctly',
test : ( done ) => {
const persistPath = path.join( __dirname, 'testSetUpPersistence' );

if ( fs.existsSync( persistPath ) )
fs.unlinkSync( persistPath );

// Wait in case the file has not been deleted from the FS
setTimeout( async () => {
const dataServer = new DataServerMap( { persist: true, persistPath } );

assert.deepStrictEqual( fs.readFileSync( persistPath ).toString(), '{"dataType":"Map","value":[]}' );

removeCache( dataServer );
done();
}, 10 );
}
});

test({
message : 'DataServerMap._setUpPersistence.works.correctly',
test : ( done ) => {
const persistPath = path.join( __dirname, 'testSetUpPersistenceBigMap' );

if ( fs.existsSync( persistPath ) )
fs.unlinkSync( persistPath );

// Wait in case the file has not been deleted from the FS
setTimeout( async () => {
const dataServer = new DataServerMap( { persist: true, persistPath, useBigMap: true } );

assert.deepStrictEqual( fs.readFileSync( persistPath ).toString(), '{"dataType":"BigMap","value":{"maps":[{"dataType":"Map","value":[]}],"_limit":14000000}}' );

removeCache( dataServer );
done();
}, 10 );
}
});

test({
message : 'DataServerMap.unlock.returns.false.on.invalid.arguments',
test : ( done ) => {
Expand Down

0 comments on commit 2e7bbcf

Please sign in to comment.