-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A few places need ot know whether or not a repo has been initialized and do so by a variety of methods - checking whether certain files exist, etc. This PR adds an `isInitialized()` method to the ipfs repo class to take some of this guesswork away as the repo will know if it's been initialized.
- Loading branch information
1 parent
ddb2f46
commit 0c016c5
Showing
5 changed files
with
50 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* eslint max-nested-callbacks: ["error", 8] */ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const chai = require('chai') | ||
chai.use(require('dirty-chai')) | ||
const expect = chai.expect | ||
const os = require('os') | ||
const path = require('path') | ||
const IPFSRepo = require('../src') | ||
|
||
describe('isInitialized', () => { | ||
let repo | ||
|
||
beforeEach(() => { | ||
const repoPath = path.join(os.tmpdir(), 'test-repo-for-' + Math.random()) | ||
repo = new IPFSRepo(repoPath) | ||
}) | ||
|
||
it('should be false before initialization', async () => { | ||
expect(await repo.isInitialized()).to.be.false() | ||
}) | ||
|
||
it('should be true after initialization', async () => { | ||
await repo.init({}) | ||
expect(await repo.isInitialized()).to.be.true() | ||
}) | ||
}) |
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