Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolved get_keystore unit test #3854

Merged
merged 5 commits into from
Apr 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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';
Copy link
Collaborator

@AMoo-Miki AMoo-Miki Apr 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this work on Windows too?

It clearly does as the tests pass.


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