Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

Commit

Permalink
docs: updates code examples
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Alan Shaw <alan@tableflip.io>
  • Loading branch information
alanshaw committed Jun 4, 2018
1 parent feb479b commit c351f5e
Showing 1 changed file with 50 additions and 10 deletions.
60 changes: 50 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Include this badge in your readme if you make a new module that implements inter
## Install

In JavaScript land:

```js
npm install interface-ipfs-core
```
Expand All @@ -68,20 +69,59 @@ In Go land:

Install `interface-ipfs-core` as one of the dependencies of your project and as a test file. Then, using `mocha` (for Node.js) or a test runner with compatible API, do:

```
var test = require('interface-ipfs-core')
var common = {
setup: function (cb) {
cb(null, IPFSFactory)
```js
const tests = require('interface-ipfs-core')

// Create common setup and teardown
const createCommon = () => ({
// Do some setup common to all tests
setup (cb) {
// Must call back with an "IPFS factory", an object with a `spawnNode` method
cb(null, {
// Use ipfsd-ctl or other to spawn an IPFS node for testing
spawnNode (cb) { /* ... */ }
})
},
teardown: function (cb) {
// Dispose of nodes created by the IPFS factory and any other teardown
teardown (cb) {
cb()
}
}
})

tests.block(createCommon)
tests.config(createCommon)
tests.dag(createCommon)
// ...etc. (see js/src/index.js)
```

#### Running tests by command

```js
tests.repo.version(createCommon)
```

#### Skipping tests

```js
tests.repo.version(createCommon)
tests.repo.stat(createCommon)
tests.repo.gc(createCommon, { skip: true }) // pass an options object to skip these tests

// OR, at the subsystem level

tests.repo(createCommon, { skip: ['gc'] })
```

#### Running only some tests

```js
tests.repo.version(createCommon)
tests.repo.stat(createCommon)
tests.repo.gc(createCommon, { only: true }) // pass an options object to run only these tests

// OR, at the subsystem level

// use all of the test suits
test.all(common)
tests.repo(createCommon, { only: ['gc'] })
```

### Go
Expand Down

0 comments on commit c351f5e

Please sign in to comment.