This repository has been archived by the owner on Mar 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add mode and mtime and .touch/.chmod mfs commands (#572)
* docs: add mode and mtime and .touch/.chmod mfs commands * docs: update arg/return types * test: updates tests to use timespecs * fix: remove cumulativeSize as it changes based on timestamps * docs: update SPEC/FILES.md * docs: update SPEC/FILES.md * docs: remove format * Update SPEC/FILES.md Co-Authored-By: Steven Allen <[email protected]> * docs: more detail about mtime values * docs: remove octal as string * docs: remove mode as strings * fix: fix up tests for optional mtime Co-authored-by: Steven Allen <[email protected]>
- Loading branch information
1 parent
f75c682
commit e10e85d
Showing
17 changed files
with
852 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const hat = require('hat') | ||
const { getDescribe, getIt, expect } = require('../utils/mocha') | ||
|
||
module.exports = (common, options) => { | ||
const describe = getDescribe(options) | ||
const it = getIt(options) | ||
|
||
describe('.files.chmod', function () { | ||
this.timeout(40 * 1000) | ||
|
||
let ipfs | ||
|
||
async function testMode (mode, expectedMode) { | ||
const testPath = `/test-${hat()}` | ||
|
||
await ipfs.files.write(testPath, Buffer.from('Hello, world!'), { | ||
create: true | ||
}) | ||
await ipfs.files.chmod(testPath, mode) | ||
|
||
const stat = await ipfs.files.stat(testPath) | ||
expect(stat).to.have.property('mode').that.equals(expectedMode) | ||
} | ||
|
||
before(async () => { | ||
ipfs = (await common.spawn()).api | ||
}) | ||
|
||
after(() => common.clean()) | ||
|
||
it('should change file mode', async function () { | ||
const mode = parseInt('544', 8) | ||
await testMode(mode, mode) | ||
}) | ||
|
||
it('should change file mode as string', async function () { | ||
const mode = parseInt('544', 8) | ||
await testMode('544', mode) | ||
}) | ||
|
||
it('should change file mode to 0', async function () { | ||
const mode = 0 | ||
await testMode(mode, mode) | ||
}) | ||
|
||
it('should change directory mode', async function () { | ||
const testPath = `/test-${hat()}` | ||
const mode = parseInt('544', 8) | ||
|
||
await ipfs.files.mkdir(testPath, { | ||
create: true | ||
}) | ||
await ipfs.files.chmod(testPath, mode) | ||
|
||
const stat = await ipfs.files.stat(testPath) | ||
expect(stat).to.have.property('mode').that.equals(mode) | ||
}) | ||
}) | ||
} |
Oops, something went wrong.