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

test: tests and updated documentation for recursive dns #455

Merged
merged 2 commits into from
Apr 8, 2019
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
9 changes: 7 additions & 2 deletions SPEC/MISCELLANEOUS.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,14 @@ A great source of [examples](https://github.com/ipfs/interface-ipfs-core/blob/ma

> Resolve DNS links

##### `ipfs.dns(domain, [callback])`
##### `ipfs.dns(domain, [options], [callback])`

`callback` must follow `function (err, path) {}` signature, where `err` is an error if the operation was not successful. `path` is the IPFS path for that domain.
Where:

- `options` is an optional object argument that might include the following properties:
- `recursive` (boolean, default true): resolve until result is not a domain name

- `callback` must follow `function (err, path) {}` signature, where `err` is an error if the operation was not successful. `path` is the IPFS path for that domain.

If no `callback` is passed, a promise is returned.

Expand Down
23 changes: 23 additions & 0 deletions src/miscellaneous/dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,28 @@ module.exports = (createCommon, options) => {
done()
})
})

// skipping because there is an error in https://ipfs.io/api/v0/dns?arg=ipfs.io
// unskip when it is resolved and the new version released: https://github.com/ipfs/go-ipfs/issues/6086
it.skip('should non-recursively resolve ipfs.io', () => {
return ipfs.dns('ipfs.io', { recursive: false }).then(res => {
// matches pattern /ipns/<ipnsaddress>
expect(res).to.match(/\/ipns\/.+$/)
})
})

it('should recursively resolve ipfs.io', () => {
return ipfs.dns('ipfs.io', { recursive: true }).then(res => {
// matches pattern /ipfs/<hash>
expect(res).to.match(/\/ipfs\/.+$/)
})
})

it('should resolve subdomain docs.ipfs.io', () => {
return ipfs.dns('docs.ipfs.io').then(res => {
// matches pattern /ipfs/<hash>
expect(res).to.match(/\/ipfs\/.+$/)
})
})
})
}