From 29dc5c4f60c5ccce1fd46736a64f096903d2d791 Mon Sep 17 00:00:00 2001 From: Victor Bjelkholm Date: Thu, 10 Nov 2016 13:11:20 +0100 Subject: [PATCH] Adjust to new cli test + add get test --- test/cli/test-files.js | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/test/cli/test-files.js b/test/cli/test-files.js index 7298352c96..89a006ed0e 100644 --- a/test/cli/test-files.js +++ b/test/cli/test-files.js @@ -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', () => { @@ -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) => { @@ -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([