From a5d2833ea5afddd618243911b9f4dfc45f3a4d5e Mon Sep 17 00:00:00 2001 From: Harry Lachenmayer Date: Tue, 17 Jul 2018 17:40:02 +0100 Subject: [PATCH 1/2] Add the example file as a basic test --- package-lock.json | 36 ++++++++++++++++++++++++++++++++++++ package.json | 3 ++- test.js | 24 ++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 test.js diff --git a/package-lock.json b/package-lock.json index 0a98c04..7644669 100644 --- a/package-lock.json +++ b/package-lock.json @@ -158,6 +158,23 @@ "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "requires": { + "minimist": "0.0.8" + }, + "dependencies": { + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + } + } + }, "object-inspect": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.6.0.tgz", @@ -186,6 +203,25 @@ "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz", "integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=" }, + "random-access-file": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/random-access-file/-/random-access-file-2.0.1.tgz", + "integrity": "sha512-nb4fClpzoUY+v1SHrro+9yykN90eMA1rc+xM39tnZ5R3BgFY+J/NxPZ0KuUpishEsvnwou9Fvm2wa3cjeuG7vg==", + "dev": true, + "requires": { + "mkdirp": "^0.5.1", + "random-access-storage": "^1.1.1" + } + }, + "random-access-storage": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/random-access-storage/-/random-access-storage-1.3.0.tgz", + "integrity": "sha512-pdS9Mcb9TB7oICypPRALlheaSuszuAKmLVEPKJMuYor7R/zDuHh5ALuQoS+ox31XRwQUL+tDwWH2GPdyspwelA==", + "dev": true, + "requires": { + "inherits": "^2.0.3" + } + }, "resolve": { "version": "1.7.1", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.7.1.tgz", diff --git a/package.json b/package.json index f1ca378..813f953 100644 --- a/package.json +++ b/package.json @@ -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": [ diff --git a/test.js b/test.js new file mode 100644 index 0000000..4ddc767 --- /dev/null +++ b/test.js @@ -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` + } +) \ No newline at end of file From 1a8446249cf11c0d79f74793b37a9bd6d22cdcfe Mon Sep 17 00:00:00 2001 From: Harry Lachenmayer Date: Tue, 17 Jul 2018 18:03:32 +0100 Subject: [PATCH 2/2] add test script to package.json --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 813f953..702493f 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,8 @@ ] }, "scripts": { - "precommit": "lint-staged" + "precommit": "lint-staged", + "test": "node test.js" }, "repository": { "type": "git",