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

Commit

Permalink
resolved get_keystore unit test (opensearch-project#3854)
Browse files Browse the repository at this point in the history
Signed-off-by: David Sinclair <[email protected]>
  • Loading branch information
Aigerim-ai authored and sikhote committed Apr 24, 2023
1 parent b62d18e commit 59d001d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [Vis Builder] Adds field unit tests ([#3211](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3211))
- [BWC Tests] Add BWC tests for 2.6.0 ([#3356](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3356))
- Prevent primitive linting limitations from being applied to unit tests found under `src/setup_node_env` ([#3403](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3403))
- [Tests] Fix unit tests for `get_keystore` ([#3854](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3854))
- [Tests] Use `scripts/use_node` instead of `node` in functional test plugins ([#3783](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3783))

## [2.x]
Expand Down
14 changes: 10 additions & 4 deletions src/cli_keystore/get_keystore.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import { getKeystore } from './get_keystore';
import { Logger } from '../cli_plugin/lib/logger';
import fs from 'fs';
import sinon from 'sinon';
import { getConfigDirectory, getDataPath } from '@osd/utils';
import { join } from 'path';

describe('get_keystore', () => {
const sandbox = sinon.createSandbox();
Expand All @@ -45,15 +47,19 @@ describe('get_keystore', () => {
});

it('uses the config directory if there is no pre-existing keystore', () => {
const configKeystore = join(getConfigDirectory(), 'opensearch_dashboards.keystore');
const dataKeystore = join(getDataPath(), 'opensearch_dashboards.keystore');
sandbox.stub(fs, 'existsSync').returns(false);
expect(getKeystore()).toContain('config');
expect(getKeystore()).not.toContain('data');
expect(getKeystore()).toContain(configKeystore);
expect(getKeystore()).not.toContain(dataKeystore);
});

it('uses the data directory if there is a pre-existing keystore in the data directory', () => {
const configKeystore = join(getConfigDirectory(), 'opensearch_dashboards.keystore');
const dataKeystore = join(getDataPath(), 'opensearch_dashboards.keystore');
sandbox.stub(fs, 'existsSync').returns(true);
expect(getKeystore()).toContain('data');
expect(getKeystore()).not.toContain('config');
expect(getKeystore()).toContain(dataKeystore);
expect(getKeystore()).not.toContain(configKeystore);
});

it('logs a deprecation warning if the data directory is used', () => {
Expand Down

0 comments on commit 59d001d

Please sign in to comment.