Skip to content
This repository has been archived by the owner on Dec 1, 2024. It is now read-only.

Add code coverage #253

Merged
merged 3 commits into from
Jul 7, 2018
Merged
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
node_modules
coverage
.nyc_output
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ matrix:

script:
- DEBUG=airtap:* npm run $CMD

after_success: npm run coverage
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
![Node version](https://img.shields.io/node/v/abstract-leveldown.svg)
[![Travis](https://travis-ci.org/Level/abstract-leveldown.svg?branch=master)](http://travis-ci.org/Level/abstract-leveldown)
[![david](https://david-dm.org/Level/abstract-leveldown.svg)](https://david-dm.org/level/abstract-leveldown)
[![Coverage Status](https://coveralls.io/repos/github/Level/abstract-leveldown/badge.svg)](https://coveralls.io/github/Level/abstract-leveldown)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
[![npm](https://img.shields.io/npm/dm/abstract-leveldown.svg)](https://www.npmjs.com/package/abstract-leveldown)

Expand Down Expand Up @@ -153,7 +154,7 @@ Provided with the current instance of `AbstractLevelDOWN` by default.

## Test Suite

To prove that your implementation is `abstract-leveldown` compliant, include the test suite found in `abstract/`. For examples please see the test suites of implementations like [`leveldown`](https://github.com/Level/leveldown), [`level-js`](https://github.com/Level/level-js) or [`memdown`](https://github.com/Level/memdown).
To prove that your implementation is `abstract-leveldown` compliant, include the test suite found in `test/`. For examples please see the test suites of implementations like [`leveldown`](https://github.com/Level/leveldown), [`level-js`](https://github.com/Level/level-js) or [`memdown`](https://github.com/Level/memdown).

As not every implementation can be fully compliant due to limitations of its underlying storage, some tests may be skipped.

Expand Down
18 changes: 17 additions & 1 deletion UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ This document describes breaking changes and how to upgrade. For a complete list

## Unreleased

### Abstract test suite has moved

If you previously did:

```js
require('abstract-leveldown/abstract/get-test')
require('abstract-leveldown/abstract/put-test') // etc
```

You must now do:

```js
require('abstract-leveldown/test/get-test')
require('abstract-leveldown/test/put-test') // etc
```

### Default `testCommon` is for disk-based, Node.js implementations only

If your implementation or its target environment doesn't meet these criteria, you must implement a custom `testCommon`.
Expand All @@ -19,7 +35,7 @@ const testCommon = require('abstract-leveldown/testCommon')
You must now do:

```js
const testCommon = require('abstract-leveldown/test-common')
const testCommon = require('abstract-leveldown/test/common')
```

### Default `testCommon` uses unique temporary directories
Expand Down
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,20 @@
},
"devDependencies": {
"airtap": "0.1.0",
"coveralls": "~3.0.2",
"nyc": "~12.0.2",
"sinon": "^6.0.0",
"standard": "^11.0.0",
"tape": "^4.7.0"
},
"scripts": {
"test": "standard && node test.js",
"test-browsers": "airtap --loopback airtap.local test.js",
"test-browser-local": "airtap --local test.js"
"test": "standard && nyc node test.js",
"test-browsers": "airtap --coverage --loopback airtap.local test.js",
"test-browser-local": "airtap --coverage --local test.js",
"coverage": "nyc report --reporter=text-lcov | coveralls"
},
"browser": {
"./test-common.js": "./test-common-browser.js"
"./test/common.js": "./test/common-browser.js"
},
"license": "MIT",
"engines": {
Expand Down
58 changes: 29 additions & 29 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
var test = require('tape')
var sinon = require('sinon')
var inherits = require('util').inherits
var testCommon = require('./test-common')
var testCommon = require('./test/common')
var AbstractLevelDOWN = require('./').AbstractLevelDOWN
var AbstractIterator = require('./').AbstractIterator
var AbstractChainedBatch = require('./').AbstractChainedBatch
Expand All @@ -16,46 +16,46 @@ function factory (location) {
* Compatibility with basic LevelDOWN API
*/

require('./abstract/leveldown-test').args(factory, test)
require('./test/leveldown-test').args(factory, test)

require('./abstract/open-test').args(factory, test, testCommon)
require('./test/open-test').args(factory, test, testCommon)

require('./abstract/del-test').setUp(factory, test, testCommon)
require('./abstract/del-test').args(test)
require('./test/del-test').setUp(factory, test, testCommon)
require('./test/del-test').args(test)

require('./abstract/get-test').setUp(factory, test, testCommon)
require('./abstract/get-test').args(test)
require('./test/get-test').setUp(factory, test, testCommon)
require('./test/get-test').args(test)

require('./abstract/put-test').setUp(factory, test, testCommon)
require('./abstract/put-test').args(test)
require('./test/put-test').setUp(factory, test, testCommon)
require('./test/put-test').args(test)

require('./abstract/put-get-del-test').setUp(factory, test, testCommon)
require('./abstract/put-get-del-test').errorKeys(test)
// require('./abstract/put-get-del-test').nonErrorKeys(test, testCommon)
require('./abstract/put-get-del-test').errorValues()
require('./abstract/put-get-del-test').tearDown(test, testCommon)
require('./test/put-get-del-test').setUp(factory, test, testCommon)
require('./test/put-get-del-test').errorKeys(test)
// require('./test/put-get-del-test').nonErrorKeys(test, testCommon)
require('./test/put-get-del-test').errorValues()
require('./test/put-get-del-test').tearDown(test, testCommon)

require('./abstract/batch-test').setUp(factory, test, testCommon)
require('./abstract/batch-test').args(test)
require('./test/batch-test').setUp(factory, test, testCommon)
require('./test/batch-test').args(test)

require('./abstract/chained-batch-test').setUp(factory, test, testCommon)
require('./abstract/chained-batch-test').args(test)
require('./test/chained-batch-test').setUp(factory, test, testCommon)
require('./test/chained-batch-test').args(test)

require('./abstract/close-test').close(factory, test, testCommon)
require('./test/close-test').close(factory, test, testCommon)

require('./abstract/iterator-test').setUp(factory, test, testCommon)
require('./abstract/iterator-test').args(test)
require('./abstract/iterator-test').sequence(test)
require('./abstract/iterator-test').tearDown(test, testCommon)
require('./test/iterator-test').setUp(factory, test, testCommon)
require('./test/iterator-test').args(test)
require('./test/iterator-test').sequence(test)
require('./test/iterator-test').tearDown(test, testCommon)

require('./abstract/iterator-range-test').setUp(factory, test, testCommon, [])
require('./abstract/iterator-range-test').tearDown(test, testCommon)
require('./test/iterator-range-test').setUp(factory, test, testCommon, [])
require('./test/iterator-range-test').tearDown(test, testCommon)

require('./abstract/iterator-snapshot-test').setUp(factory, test, testCommon)
require('./abstract/iterator-snapshot-test').tearDown(test, testCommon)
require('./test/iterator-snapshot-test').setUp(factory, test, testCommon)
require('./test/iterator-snapshot-test').tearDown(test, testCommon)

require('./abstract/iterator-no-snapshot-test').setUp(factory, test, testCommon)
require('./abstract/iterator-no-snapshot-test').tearDown(test, testCommon)
require('./test/iterator-no-snapshot-test').setUp(factory, test, testCommon)
require('./test/iterator-no-snapshot-test').tearDown(test, testCommon)

function implement (ctor, methods) {
function Test () {
Expand Down
2 changes: 1 addition & 1 deletion abstract/batch-test.js → test/batch-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ module.exports.tearDown = function (test, testCommon) {
}

module.exports.all = function (leveldown, test, testCommon) {
testCommon = testCommon || require('../test-common')
testCommon = testCommon || require('./common')
module.exports.setUp(leveldown, test, testCommon)
module.exports.args(test)
module.exports.batch(test)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ module.exports.tearDown = function (test, testCommon) {
}

module.exports.all = function (leveldown, test, testCommon) {
testCommon = testCommon || require('../test-common')
testCommon = testCommon || require('./common')
module.exports.setUp(leveldown, test, testCommon)
module.exports.args(test)
module.exports.batch(test, testCommon)
Expand Down
2 changes: 1 addition & 1 deletion abstract/close-test.js → test/close-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports.close = function (leveldown, test, testCommon) {
testCommon = testCommon || require('../test-common')
testCommon = testCommon || require('./common')
test('test close()', function (t) {
var db = leveldown(testCommon.location())

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion abstract/del-test.js → test/del-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ module.exports.tearDown = function (test, testCommon) {
}

module.exports.all = function (leveldown, test, testCommon) {
testCommon = testCommon || require('../test-common')
testCommon = testCommon || require('./common')
module.exports.setUp(leveldown, test, testCommon)
module.exports.args(test)
module.exports.del(test)
Expand Down
2 changes: 1 addition & 1 deletion abstract/get-test.js → test/get-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ module.exports.tearDown = function (test, testCommon) {
}

module.exports.all = function (leveldown, test, testCommon) {
testCommon = testCommon || require('../test-common')
testCommon = testCommon || require('./common')
module.exports.setUp(leveldown, test, testCommon)
module.exports.args(test)
module.exports.get(test)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ exports.tearDown = function (test, testCommon) {
}

exports.all = function (leveldown, test, testCommon) {
testCommon = testCommon || require('../test-common')
testCommon = testCommon || require('./common')
exports.setUp(leveldown, test, testCommon)
exports.noSnapshot(leveldown, test, testCommon)
exports.tearDown(test, testCommon)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ module.exports.tearDown = function (test, testCommon) {
}

module.exports.all = function (leveldown, test, testCommon) {
testCommon = testCommon || require('../test-common')
testCommon = testCommon || require('./common')

var data = (function () {
var d = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ exports.tearDown = function (test, testCommon) {
}

exports.all = function (leveldown, test, testCommon) {
testCommon = testCommon || require('../test-common')
testCommon = testCommon || require('./common')
exports.setUp(leveldown, test, testCommon)
exports.snapshot(leveldown, test, testCommon)
exports.tearDown(test, testCommon)
Expand Down
2 changes: 1 addition & 1 deletion abstract/iterator-test.js → test/iterator-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ module.exports.tearDown = function (test, testCommon) {
}

module.exports.all = function (leveldown, test, testCommon) {
testCommon = testCommon || require('../test-common')
testCommon = testCommon || require('./common')
module.exports.setUp(leveldown, test, testCommon)
module.exports.args(test)
module.exports.sequence(test)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion abstract/open-test.js → test/open-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ module.exports.tearDown = function (test, testCommon) {
}

module.exports.all = function (leveldown, test, testCommon) {
testCommon = testCommon || require('../test-common')
testCommon = testCommon || require('./common')
module.exports.setUp(test, testCommon)
module.exports.args(leveldown, test, testCommon)
module.exports.open(leveldown, test, testCommon)
Expand Down
2 changes: 1 addition & 1 deletion abstract/put-get-del-test.js → test/put-get-del-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ module.exports.tearDown = function (test, testCommon) {
}

module.exports.all = function (leveldown, test, testCommon) {
testCommon = testCommon || require('../test-common')
testCommon = testCommon || require('./common')
module.exports.setUp(leveldown, test, testCommon)
module.exports.errorKeys(test)
module.exports.nonErrorKeys(test)
Expand Down
2 changes: 1 addition & 1 deletion abstract/put-test.js → test/put-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ module.exports.tearDown = function (test, testCommon) {
}

module.exports.all = function (leveldown, test, testCommon) {
testCommon = testCommon || require('../test-common')
testCommon = testCommon || require('./common')
module.exports.setUp(leveldown, test, testCommon)
module.exports.args(test)
module.exports.put(test)
Expand Down
File renamed without changes.