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

test: adds tests for metadata with mfs stat and files.add #1221

Merged
merged 2 commits into from
Jan 23, 2020
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"cross-env": "^6.0.0",
"detect-node": "^2.0.4",
"go-ipfs-dep": "^0.4.22",
"interface-ipfs-core": "^0.127.0",
"interface-ipfs-core": "^0.128.0",
"ipfsd-ctl": "^1.0.0",
"ndjson": "^1.5.0",
"nock": "^11.4.0",
Expand Down
13 changes: 10 additions & 3 deletions src/add/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module.exports = configure(({ ky }) => {

for await (let file of ndjson(toIterable(res.body))) {
file = toCamel(file)
// console.log(file)

if (options.progress && file.bytes) {
options.progress(file.bytes)
} else {
Expand All @@ -52,16 +52,23 @@ module.exports = configure(({ ky }) => {
}
})

function toCoreInterface ({ name, hash, size, mode, mtime }) {
function toCoreInterface ({ name, hash, size, mode, mtime, mtimeNsecs }) {
const output = {
path: name,
hash,
size: parseInt(size)
}

if (mode !== undefined) {
if (mode != null) {
output.mode = parseInt(mode, 8)
}

if (mtime != null) {
output.mtime = {
secs: mtime,
nsecs: mtimeNsecs || 0
}
}

return output
}
1 change: 1 addition & 0 deletions src/files/cp.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = configure(({ ky }) => {
if (options.flush != null) searchParams.set('flush', options.flush)
if (options.hashAlg) searchParams.set('hash', options.hashAlg)
if (options.parents != null) searchParams.set('parents', options.parents)
if (options.shardSplitThreshold != null) searchParams.set('shardSplitThreshold', options.shardSplitThreshold)

return ky.post('files/cp', {
timeout: options.timeout,
Expand Down
1 change: 1 addition & 0 deletions src/files/mkdir.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = configure(({ ky }) => {
if (options.flush != null) searchParams.set('flush', options.flush)
if (options.hashAlg) searchParams.set('hash', options.hashAlg)
if (options.parents != null) searchParams.set('parents', options.parents)
if (options.shardSplitThreshold != null) searchParams.set('shardSplitThreshold', options.shardSplitThreshold)
if (mtime) {
searchParams.set('mtime', mtime.secs)

Expand Down
1 change: 1 addition & 0 deletions src/files/mv.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = configure(({ ky }) => {
if (options.flush != null) searchParams.set('flush', options.flush)
if (options.hashAlg) searchParams.set('hash', options.hashAlg)
if (options.parents != null) searchParams.set('parents', options.parents)
if (options.shardSplitThreshold != null) searchParams.set('shardSplitThreshold', options.shardSplitThreshold)

return ky.post('files/mv', {
timeout: options.timeout,
Expand Down
1 change: 1 addition & 0 deletions src/files/rm.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = configure(({ ky }) => {
searchParams.append('arg', path)
if (options.recursive != null) searchParams.set('recursive', options.recursive)
if (options.force != null) searchParams.set('force', options.force)
if (options.shardSplitThreshold != null) searchParams.set('shardSplitThreshold', options.shardSplitThreshold)

return ky.post('files/rm', {
timeout: options.timeout,
Expand Down
1 change: 1 addition & 0 deletions src/files/write.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module.exports = configure(({ ky }) => {
if (options.parents != null) searchParams.set('parents', options.parents)
if (options.rawLeaves != null) searchParams.set('raw-leaves', options.rawLeaves)
if (options.truncate != null) searchParams.set('truncate', options.truncate)
if (options.shardSplitThreshold != null) searchParams.set('shardSplitThreshold', options.shardSplitThreshold)
if (mtime) {
searchParams.set('mtime', mtime.secs)

Expand Down
24 changes: 24 additions & 0 deletions test/interface.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,30 @@ describe('interface-ipfs-core tests', () => {
{
name: 'should write file and specify mtime as hrtime',
reason: 'TODO not implemented in go-ipfs yet'
},
{
name: 'should stat file with mode',
reason: 'TODO not implemented in go-ipfs yet'
},
{
name: 'should stat file with mtime',
reason: 'TODO not implemented in go-ipfs yet'
},
{
name: 'should stat dir with mode',
reason: 'TODO not implemented in go-ipfs yet'
},
{
name: 'should stat dir with mtime',
reason: 'TODO not implemented in go-ipfs yet'
},
{
name: 'should stat sharded dir with mode',
reason: 'TODO not implemented in go-ipfs yet'
},
{
name: 'should stat sharded dir with mtime',
reason: 'TODO not implemented in go-ipfs yet'
}
]
})
Expand Down