Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit a4831ee

Browse files
committed
test: add basic refs test
1 parent 12ad091 commit a4831ee

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

test/cli/refs.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/* eslint-env mocha */
2+
'use strict'
3+
4+
const expect = require('chai').expect
5+
const runOnAndOff = require('../utils/on-and-off')
6+
7+
// Note: There are more comprehensive tests in interface-js-ipfs-core
8+
describe('refs', () => runOnAndOff((thing) => {
9+
let ipfs
10+
11+
before(() => {
12+
ipfs = thing.ipfs
13+
return ipfs('add -r test/fixtures/test-data/recursive-get-dir')
14+
})
15+
16+
it('prints added files', function () {
17+
this.timeout(20 * 1000)
18+
19+
return ipfs('refs Qmaj2NmcyAXT8dFmZRRytE12wpcaHADzbChKToMEjBsj5Z')
20+
.then((out) => {
21+
expect(out).to.eql(
22+
'QmamKEPmEH9RUsqRQsfNf5evZQDQPYL9KXg1ADeT7mkHkT\n' +
23+
'QmPkWYfSLCEBLZu7BZt4kigGDMe3cpogMbeVf97gN2xJDN\n' +
24+
'QmUqyZtPmsRy1U5Mo8kz2BAMmk1hfJ7yW1KAFTMB2odsFv\n' +
25+
'QmUhUuiTKkkK8J6JZ9zmj8iNHPuNfGYcszgRumzhHBxEEU\n' +
26+
'QmR56UJmAaZLXLdTT1ALrE9vVqV8soUEekm9BMd4FnuYqV\n'
27+
)
28+
})
29+
})
30+
31+
it('follows a path with recursion, <hash>/<subdir>', function () {
32+
this.timeout(20 * 1000)
33+
34+
return ipfs('refs -r --format="<linkname>" /ipfs/Qmaj2NmcyAXT8dFmZRRytE12wpcaHADzbChKToMEjBsj5Z/init-docs')
35+
.then((out) => {
36+
expect(out).to.eql(
37+
'about\n' +
38+
'contact\n' +
39+
'docs\n' +
40+
'index\n' +
41+
'help\n' +
42+
'quick-start\n' +
43+
'readme\n' +
44+
'security-notes\n' +
45+
'tour\n' +
46+
'0.0-intro\n'
47+
)
48+
})
49+
})
50+
}))

0 commit comments

Comments
 (0)