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

test(dag): ensure dag.put can be called without options #316

Merged
merged 3 commits into from
Jul 3, 2018

Conversation

0x-r4bbit
Copy link
Contributor

As discussed in ipfs/js-ipfs#1415 (comment)

0x-r4bbit added a commit to 0x-r4bbit/js-ipfs that referenced this pull request Jun 29, 2018
The [dag.put](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md#dagput) interface
takes an options object which is required, but should be optional with
decent defaults.

See dedicated test here: ipfs-inactive/interface-js-ipfs-core#316

This commit implements this behaviour.

**Before**:

```js
ipfs.dag.put(obj, options, (err, cid) => {...});
```

^ Prior to this commit, without passing `options`, this call resulted in an error.

**After**:

```js
ipfs.dag.put(obj, (err, cid) => {...});
```

^ This is now perfectly fine.

Fixes ipfs#1395

License: MIT
Signed-off-by: Pascal Precht <pascal.precht@gmail.com>
0x-r4bbit added a commit to 0x-r4bbit/js-ipfs that referenced this pull request Jun 30, 2018
The [dag.put](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md#dagput) interface
takes an options object which is required, but should be optional with
decent defaults.

See dedicated test here: ipfs-inactive/interface-js-ipfs-core#316

This commit implements this behaviour.

**Before**:

```js
ipfs.dag.put(obj, options, (err, cid) => {...});
```

^ Prior to this commit, without passing `options`, this call resulted in an error.

**After**:

```js
ipfs.dag.put(obj, (err, cid) => {...});
```

^ This is now perfectly fine.

Fixes ipfs#1395

License: MIT
Signed-off-by: Pascal Precht <pascal.precht@gmail.com>
0x-r4bbit added a commit to 0x-r4bbit/js-ipfs that referenced this pull request Jun 30, 2018
The [dag.put](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md#dagput) interface
takes an options object which is required, but should be optional with
decent defaults.

See dedicated test here: ipfs-inactive/interface-js-ipfs-core#316

This commit implements this behaviour.

**Before**:

```js
ipfs.dag.put(obj, options, (err, cid) => {...});
```

^ Prior to this commit, without passing `options`, this call resulted in an error.

**After**:

```js
ipfs.dag.put(obj, (err, cid) => {...});
```

^ This is now perfectly fine.

Fixes ipfs#1395

License: MIT
Signed-off-by: Pascal Precht <pascal.precht@gmail.com>
@vmx vmx requested a review from alanshaw July 2, 2018 09:14
Copy link
Contributor

@vmx vmx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sound OK to me, but I feel like missing a bit of the context that @alanshaw has, hence requesting another review from him :)

0x-r4bbit added a commit to 0x-r4bbit/js-ipfs that referenced this pull request Jul 2, 2018
The [dag.put](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md#dagput) interface
takes an options object which is required, but should be optional with
decent defaults.

See dedicated test here: ipfs-inactive/interface-js-ipfs-core#316

This commit implements this behaviour.

**Before**:

```js
ipfs.dag.put(obj, options, (err, cid) => {...});
```

^ Prior to this commit, without passing `options`, this call resulted in an error.

**After**:

```js
ipfs.dag.put(obj, (err, cid) => {...});
```

^ This is now perfectly fine.

Fixes ipfs#1395

License: MIT
Signed-off-by: Pascal Precht <pascal.precht@gmail.com>
0x-r4bbit added a commit to 0x-r4bbit/js-ipfs that referenced this pull request Jul 2, 2018
The [dag.put](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md#dagput) interface
takes an options object which is required, but should be optional with
decent defaults.

See dedicated test here: ipfs-inactive/interface-js-ipfs-core#316

This commit implements this behaviour.

**Before**:

```js
ipfs.dag.put(obj, options, (err, cid) => {...});
```

^ Prior to this commit, without passing `options`, this call resulted in an error.

**After**:

```js
ipfs.dag.put(obj, (err, cid) => {...});
```

^ This is now perfectly fine.

Fixes ipfs#1395

License: MIT
Signed-off-by: Pascal Precht <pascal.precht@gmail.com>
Copy link
Contributor

@alanshaw alanshaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM. Would you mind also updating the dag.put spec document to add the default values?

@@ -113,6 +113,10 @@ module.exports = (createCommon, options) => {
})
})

it('shouldn\'t fail when calling put without options', (done) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency could you please use "should not" over "shouldn't"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 👍

0x-r4bbit added a commit to 0x-r4bbit/js-ipfs that referenced this pull request Jul 2, 2018
The [dag.put](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md#dagput) interface
takes an options object which is required, but should be optional with
decent defaults.

See dedicated test here: ipfs-inactive/interface-js-ipfs-core#316

This commit implements this behaviour.

**Before**:

```js
ipfs.dag.put(obj, options, (err, cid) => {...});
```

^ Prior to this commit, without passing `options`, this call resulted in an error.

**After**:

```js
ipfs.dag.put(obj, (err, cid) => {...});
```

^ This is now perfectly fine.

Fixes ipfs#1395

License: MIT
Signed-off-by: Pascal Precht <pascal.precht@gmail.com>
0x-r4bbit added a commit to 0x-r4bbit/js-ipfs that referenced this pull request Jul 2, 2018
The [dag.put](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md#dagput) interface
takes an options object which is required, but should be optional with
decent defaults.

See dedicated test here: ipfs-inactive/interface-js-ipfs-core#316

This commit implements this behaviour.

**Before**:

```js
ipfs.dag.put(obj, options, (err, cid) => {...});
```

^ Prior to this commit, without passing `options`, this call resulted in an error.

**After**:

```js
ipfs.dag.put(obj, (err, cid) => {...});
```

^ This is now perfectly fine.

Fixes ipfs#1395

License: MIT
Signed-off-by: Pascal Precht <pascal.precht@gmail.com>
License: MIT
Signed-off-by: Pascal Precht <pascal.precht@gmail.com>
@0x-r4bbit
Copy link
Contributor Author

@alanshaw updated the spec document. Let me know if that's how you imagined it, or if the wording needs change.

Copy link
Contributor

@alanshaw alanshaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

0x-r4bbit added a commit to 0x-r4bbit/js-ipfs that referenced this pull request Jul 2, 2018
The [dag.put](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md#dagput) interface
takes an options object which is required, but should be optional with
decent defaults.

See dedicated test here: ipfs-inactive/interface-js-ipfs-core#316

This commit implements this behaviour.

**Before**:

```js
ipfs.dag.put(obj, options, (err, cid) => {...});
```

^ Prior to this commit, without passing `options`, this call resulted in an error.

**After**:

```js
ipfs.dag.put(obj, (err, cid) => {...});
```

^ This is now perfectly fine.

Fixes ipfs#1395

License: MIT
Signed-off-by: Pascal Precht <pascal.precht@gmail.com>
0x-r4bbit added a commit to 0x-r4bbit/js-ipfs that referenced this pull request Jul 2, 2018
The [dag.put](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md#dagput) interface
takes an options object which is required, but should be optional with
decent defaults.

See dedicated test here: ipfs-inactive/interface-js-ipfs-core#316

This commit implements this behaviour.

**Before**:

```js
ipfs.dag.put(obj, options, (err, cid) => {...});
```

^ Prior to this commit, without passing `options`, this call resulted in an error.

**After**:

```js
ipfs.dag.put(obj, (err, cid) => {...});
```

^ This is now perfectly fine.

Fixes ipfs#1395

License: MIT
Signed-off-by: Pascal Precht <pascal.precht@gmail.com>
License: MIT
Signed-off-by: Alan Shaw <alan@tableflip.io>
@ghost ghost assigned alanshaw Jul 3, 2018
@ghost ghost added the in progress label Jul 3, 2018
@alanshaw
Copy link
Contributor

alanshaw commented Jul 3, 2018

@PascalPrecht I added a test to ensure the defaults are set according to the spec and changed the input to the cborNode variable since that is what will be created.

@alanshaw alanshaw merged commit 011c417 into ipfs-inactive:master Jul 3, 2018
@ghost ghost removed the in progress label Jul 3, 2018
@0x-r4bbit
Copy link
Contributor Author

🎉 @alanshaw thanks!

I should've added such a test in the first place.... next time! :)

@0x-r4bbit 0x-r4bbit deleted the fix/dag-put branch July 3, 2018 08:27
alanshaw pushed a commit to ipfs/js-ipfs that referenced this pull request Jul 3, 2018
* fix(core/components/dag): make options in `put` API optional

The [dag.put](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md#dagput) interface
takes an options object which is required, but should be optional with
decent defaults.

See dedicated test here: ipfs-inactive/interface-js-ipfs-core#316

This commit implements this behaviour.

**Before**:

```js
ipfs.dag.put(obj, options, (err, cid) => {...});
```

^ Prior to this commit, without passing `options`, this call resulted in an error.

**After**:

```js
ipfs.dag.put(obj, (err, cid) => {...});
```

^ This is now perfectly fine.

Fixes #1395

License: MIT
Signed-off-by: Pascal Precht <pascal.precht@gmail.com>

* chore: update interface-ipfs-core dependency

License: MIT
Signed-off-by: Alan Shaw <alan@tableflip.io>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants