Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5658 from LiskHQ/5598-fix-data-path
Plugins data should be associated to the data path of the application - Closes #5598
- Loading branch information
Showing
5 changed files
with
56 additions
and
15 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
45 changes: 45 additions & 0 deletions
45
framework-plugins/lisk-framework-forger-plugin/test/unit/db.spec.ts
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,45 @@ | ||
/* | ||
* Copyright © 2020 Lisk Foundation | ||
* | ||
* See the LICENSE file at the top-level directory of this distribution | ||
* for licensing information. | ||
* | ||
* Unless otherwise agreed in a custom licensing agreement with the Lisk Foundation, | ||
* no part of this software, including this file, may be copied, modified, | ||
* propagated, or distributed except according to the terms contained in the | ||
* LICENSE file. | ||
* | ||
* Removal or modification of this copyright notice is prohibited. | ||
*/ | ||
|
||
import * as fs from 'fs-extra'; | ||
import { homedir } from 'os'; | ||
import { join } from 'path'; | ||
import { getDBInstance } from '../../src/db'; | ||
|
||
jest.mock('fs-extra'); | ||
jest.mock('@liskhq/lisk-db'); | ||
const mockedFsExtra = fs as jest.Mocked<typeof fs>; | ||
|
||
describe('Plugins DB', () => { | ||
const unresolvedRootPath = '~/.lisk/devnet'; | ||
const dbName = 'lisk-framework-forger-plugin.db'; | ||
|
||
it('should resolve to data directory', async () => { | ||
await getDBInstance(unresolvedRootPath); | ||
const rootPath = unresolvedRootPath.replace('~', homedir()); | ||
const dirPath = join(rootPath, 'plugins/data', dbName); | ||
|
||
expect(mockedFsExtra.ensureDir).toBeCalledWith(dirPath); | ||
}); | ||
|
||
it('should resolve to default plugin data path', async () => { | ||
const customUnresolvedRootPath = '~/.lisk/devnet/custom/path'; | ||
|
||
await getDBInstance(customUnresolvedRootPath); | ||
const rootPath = customUnresolvedRootPath.replace('~', homedir()); | ||
const dirPath = join(rootPath, 'plugins/data', dbName); | ||
|
||
expect(mockedFsExtra.ensureDir).toBeCalledWith(dirPath); | ||
}); | ||
}); |
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