From e676534f051a4363922127bc40488c959def5d7b Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Mon, 17 Apr 2023 16:01:04 -0700 Subject: [PATCH] resolved get_keystore unit test (#3854) (#3864) (cherry picked from commit 677dcbd039b39a662928ea6ab62a3305c97ac24e) Signed-off-by: github-actions[bot] # Conflicts: # CHANGELOG.md Co-authored-by: github-actions[bot] --- src/cli_keystore/get_keystore.test.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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', () => {