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

Commit

Permalink
Updated Usage with working code
Browse files Browse the repository at this point in the history
I was not able to get it working as it was; this should help a bit. See #43 (comment)
  • Loading branch information
RichardLitt committed Jul 6, 2016
1 parent bb63627 commit 2e4d611
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 24 deletions.
51 changes: 28 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
## Table of Contents

- [Table of Contents](#table-of-contents)
- [Background](#background)
- [Modules that implement the interface](#modules-that-implement-the-interface)
- [Badge](#badge)
Expand All @@ -17,22 +18,6 @@
- [Node.js](#nodejs)
- [Go](#go)
- [API](#api)
- [Files](/API/files)
- [`add`](/API/files#add)
- [`createAddStream`](/files#createaddstream)
- [`cat`](/API/files#cat)
- [Object](/API/object)
- [`object.new`](/API/object#objectnew)
- [`object.put`](/API/object#objectput)
- [`object.get`](/API/object#objectget)
- [`object.data`](/API/object#objectdata)
- [`object.links`](/API/object#objectlinks)
- [`object.stat`](/API/object#objectstat)
- [`object.patch`](/API/object#objectpatch)
- [`object.patch.addLink`](/API/object#objectpatchaddlink)
- [`object.patch.rmLink`](/API/object#objectpatchrmlink)
- [`object.patch.appendData`](/API/object#objectpatchappenddata)
- [`object.patch.setData`](/API/object#objectpatchsetdata)
- [Contribute](#contribute)
- [Want to hack on IPFS?](#want-to-hack-on-ipfs)
- [License](#license)
Expand Down Expand Up @@ -75,22 +60,42 @@ In Go land:

### Node.js

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:
Install `interface-ipfs-core` as one of the dependencies of your project. Install the following test file:

```
var test = require('interface-ipfs-core')
```js
/* eslint-env mocha */
'use strict'

const test = require('interface-ipfs-core')
const IPFS = require('ipfs')

var common = {
const common = {
setup: function (cb) {
cb(null, yourIPFSInstance)
const ipfs = new IPFS()
ipfs.load(() => {
cb(null, ipfs)
})
},
teardown: function (cb) {
cb()
}
}

// use all of the test suits
test.all(common)
test.files(common)
```

Then, using `mocha` (for Node.js) or a test runner with compatible API, do:

```sh
mocha test.js
```

To test this yourself, you can clone this repo and run a test on [test.js](test.js):

```sh
npm install
npm install -g mocha
mocha test.js
```

### Go
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"readable-stream": "1.1.13"
},
"devDependencies": {
"aegir": "^3.2.0"
"aegir": "^3.2.0",
"ipfs": "^0.14.1"
},
"contributors": [
"David Dias <[email protected]>",
Expand Down
19 changes: 19 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* eslint-env mocha */
'use strict'

const test = require('./src/index.js') // Replace with interface-ipfs-core in your repo
const IPFS = require('ipfs')

const common = {
setup: function (cb) {
const ipfs = new IPFS() // Replace with your instance
ipfs.load(() => {
cb(null, ipfs)
})
},
teardown: function (cb) {
cb()
}
}

test.files(common)

0 comments on commit 2e4d611

Please sign in to comment.