This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
74 additions
and
47 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
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 |
---|---|---|
@@ -1,59 +1,69 @@ | ||
/* eslint max-nested-callbacks: ["error", 5] */ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const fs = require('fs') | ||
const path = require('path') | ||
const os = require('os') | ||
const expect = require('chai').expect | ||
const repoVersion = require('ipfs-repo').repoVersion | ||
const pkgversion = require('../../package.json').version | ||
const runOnAndOff = require('../utils/on-and-off') | ||
|
||
function getRepoVersion (repoPath) { | ||
const versionPath = path.join(repoPath, 'version') | ||
return String(fs.readFileSync(versionPath)) | ||
} | ||
|
||
describe('version', () => runOnAndOff((thing) => { | ||
let ipfs | ||
let repoVersion | ||
|
||
before(() => { | ||
ipfs = thing.ipfs | ||
repoVersion = getRepoVersion(ipfs.repoPath) | ||
}) | ||
|
||
it('get the version', () => { | ||
return ipfs('version').then((out) => { | ||
it('get the version', () => | ||
ipfs('version').then(out => | ||
expect(out).to.eql( | ||
`js-ipfs version: ${pkgversion}\n` | ||
) | ||
}) | ||
}) | ||
) | ||
) | ||
|
||
it('handles --number', () => { | ||
return ipfs('version --number').then(out => | ||
it('handles --number', () => | ||
ipfs('version --number').then(out => | ||
expect(out).to.eql(`${pkgversion}\n`) | ||
) | ||
}) | ||
) | ||
|
||
it('handles --commit', () => { | ||
return ipfs('version --commit').then(out => | ||
it('handles --commit', () => | ||
ipfs('version --commit').then(out => | ||
expect(out).to.eql(`js-ipfs version: ${pkgversion}-\n`) | ||
) | ||
}) | ||
) | ||
|
||
it('handles --all', () => { | ||
return ipfs('version --all').then(out => | ||
expect(out).to.include( | ||
`js-ipfs version: ${pkgversion}- | ||
Repo version: ${repoVersion} | ||
` | ||
) | ||
describe('handles --all', function () { | ||
it('prints js-ipfs version', () => | ||
ipfs('version --all').then(out => { | ||
expect(out).to.include(`js-ipfs version: ${pkgversion}`) | ||
}) | ||
) | ||
|
||
it('prints repo version', () => | ||
ipfs('version --all').then(out => { | ||
expect(out).to.include(`Repo version: ${repoVersion}`) | ||
}) | ||
) | ||
|
||
it('prints arch/platform', () => | ||
ipfs('version --all').then(out => { | ||
expect(out).to.include(`System version: ${os.arch()}/${os.platform()}`) | ||
}) | ||
) | ||
|
||
it('prints Node.js version', () => | ||
ipfs('version --all').then(out => { | ||
expect(out).to.include(`Node.js version: ${process.version}`) | ||
}) | ||
) | ||
}) | ||
|
||
it('handles --repo', () => { | ||
return ipfs('version --repo').then(out => { | ||
it('handles --repo', () => | ||
ipfs('version --repo').then(out => | ||
expect(out).to.eql(`${repoVersion}\n`) | ||
}) | ||
}) | ||
) | ||
) | ||
})) |
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