Skip to content

Add basic tests #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
"tape": "^4.9.1"
},
"devDependencies": {
"lint-staged": "^7.2.0",
"prettier": "^1.9.2",
"lint-staged": "^7.2.0"
"random-access-file": "^2.0.1"
},
"lint-staged": {
"*.js": [
Expand All @@ -17,7 +18,8 @@
]
},
"scripts": {
"precommit": "lint-staged"
"precommit": "lint-staged",
"test": "node test.js"
},
"repository": {
"type": "git",
Expand Down
24 changes: 24 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
var test = require("random-access-test")
var randomAccess = require("random-access-file") // Or your package instead
var path = require("path")
var os = require("os")

var tmp = path.join(
os.tmpdir(),
"random-access-file-" + process.pid + "-" + Date.now()
)
test(
function(name, options, callback) {
const file = path.join(tmp, name)
callback(randomAccess(file, options))
},
{
// Choose which test to exercise
reopen: true, // tests that re-open same file (not applicable to ram)
content: false, // tests that populates with options.content
del: true, // tests that excersise advisory del API
writable: true, // tests that excersise open with `options.writable`
size: true, // tests that excersise open with `options.size`
truncate: true // tests that excersise open with `options.truncate`
}
)