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

Commit

Permalink
Adjust to new cli test + add get test
Browse files Browse the repository at this point in the history
  • Loading branch information
victorb committed Nov 10, 2016
1 parent 700f4b6 commit 29dc5c4
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions test/cli/test-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,17 @@ const path = require('path')
const describeOnlineAndOffline = require('../utils/on-and-off')
const ipfs = require('../utils/ipfs-exec')(repoPath)

describe('files', () => {
describe.only('files', () => {
describeOnlineAndOffline(repoPath, () => {
it('cat', () => {
return ipfs('files cat QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o').then((out) => {
expect(out).to.be.eql('hello world')
})
})
it('add alias', (done) => {
nexpect.spawn('node', [process.cwd() + '/src/cli/bin.js', 'add', 'src/init-files/init-docs/readme'], {env})
.run((err, stdout, exitcode) => {
expect(err).to.not.exist
expect(exitcode).to.equal(0)
expect(stdout[0]).to.equal('added QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB readme')
done()
})
it('cat alias', () => {
return ipfs('cat QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o').then((out) => {
expect(out).to.be.eql('hello world')
})
})

it('get', () => {
Expand All @@ -41,6 +37,22 @@ describe('files', () => {
fs.unlinkSync(file)
})
})
it('get alias', () => {
return ipfs('get QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o').then((out) => {
expect(out).to.be.eql(
'Saving file(s) to QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o'
)

const file = path.join(process.cwd(), 'QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o')
expect(
fs.readFileSync(file).toString()
).to.be.eql(
'hello world\n'
)

fs.unlinkSync(file)
})
})

it('add', () => {
return ipfs('files add src/init-files/init-docs/readme').then((out) => {
Expand All @@ -50,6 +62,14 @@ describe('files', () => {
})
})

it('add alias', () => {
return ipfs('files add src/init-files/init-docs/readme').then((out) => {
expect(out).to.be.eql(
'added QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB readme'
)
})
})

it('add recursively', () => {
return ipfs('files add -r src/init-files/init-docs').then((out) => {
expect(out).to.be.eql([
Expand Down

0 comments on commit 29dc5c4

Please sign in to comment.