mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-21 08:03:13 +09:00
More tests for remoteMap
This commit is contained in:
1 parent
f131a83103
commit
2d5c0c3bbf
2 files changed
+16
-1
No files matched your search
@@ -14,8 +14,8 @@ let log = string => (allowLogging)? console.log(string):""
|
|||||||
|
|
||||||
module.exports = class chunkStore {
|
module.exports = class chunkStore {
|
||||||
constructor(name, chunkSize = 32, path = "./chunkStore/"){
|
constructor(name, chunkSize = 32, path = "./chunkStore/"){
|
||||||
|
if(!name || (typeof name != "string" && typeof name != "number")) throw new Error("chunkstore requires a name string as first param");
|
||||||
name = name.toString();
|
name = name.toString();
|
||||||
if(!name || typeof name != "string") throw new Error("chunkstore requires a name string as first param")
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.chunkSize = chunkSize;
|
this.chunkSize = chunkSize;
|
||||||
this.path = (path[path.length] == "/") ? path : path+"/";
|
this.path = (path[path.length] == "/") ? path : path+"/";
|
||||||
|
|||||||
@@ -46,4 +46,19 @@ describe("remoteMap/chunkStore.js", () => {
|
|||||||
},300);
|
},300);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
describe("validates input by throwing when it is invalid", ()=>{
|
||||||
|
it("throws if called without a string as the first parameter", ()=>{
|
||||||
|
assert.throws(()=>{
|
||||||
|
let throwingChunkStore = new chunkStore(undefined, undefined, "asdasda");
|
||||||
|
});
|
||||||
|
assert.throws(()=>{
|
||||||
|
let throwingChunkStore = new chunkStore({}, undefined, "asdasdas");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it("converts numbers to strings automatically if they are provided as the first parameter", ()=>{
|
||||||
|
assert.ok(()=>{
|
||||||
|
let nonThrowingChunkStore = new chunkStore(42, undefined, "./database/unitTests/chunkStore/");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
Reference in new issue
Block a user