From 677dcbd039b39a662928ea6ab62a3305c97ac24e Mon Sep 17 00:00:00 2001 From: Aigerim Suleimenova Date: Tue, 18 Apr 2023 01:25:16 +0600 Subject: [PATCH] resolved get_keystore unit test (#3854) --- CHANGELOG.md | 1 + src/cli_keystore/get_keystore.test.js | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 60e36f05e775..03bdc5998392 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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] diff --git a/src/cli_keystore/get_keystore.test.js b/src/cli_keystore/get_keystore.test.js index ec838a6b956f..2e05657e4ae8 100644 --- a/src/cli_keystore/get_keystore.test.js +++ b/src/cli_keystore/get_keystore.test.js @@ -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(); @@ -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', () => {