-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: clean up unit tests for worker
- Loading branch information
1 parent
23a1f20
commit 96490ac
Showing
3 changed files
with
79 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,6 @@ | ||
const MIN_KEY = 1; | ||
const MAX_KEY = 100; | ||
const TEST_INTERVAL_MS = 1000; | ||
exports.CLOSED_DB_MESSAGE = "closed db"; | ||
|
||
exports.createRandomKeys = async (db) => { | ||
for (let i = MIN_KEY; i <= MAX_KEY; i++) { | ||
await db.put(`key${i}`, `value${i}`); | ||
} | ||
}; | ||
|
||
exports.getRandomKeys = async (db, thread) => { | ||
const start = Date.now(); | ||
while (Date.now() - start < TEST_INTERVAL_MS) { | ||
const randomKey = Math.floor( | ||
Math.random() * (MAX_KEY - MIN_KEY + 1) + MIN_KEY | ||
); | ||
// console.log(thread + ": got " + | ||
await db.get(`key${randomKey}`); | ||
// ); | ||
} | ||
}; | ||
function getRandomValue(minValue, maxValue) { | ||
return Math.floor(Math.random() * (maxValue - minValue + 1) + minValue); | ||
} | ||
exports.getRandomValue = getRandomValue; |