mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-11 02:32:35 -05:00
* Updated Postgres Spec for where to find engine version, removed calling calling -ev in edit commands (#14735) * Added spec.engine.version, took out calling engine version with edit calls * Added text wrong place * missed updates * PR fix * Update Arc Postgres troubleshooting notebook Co-authored-by: Brian Bergeron <brberger@microsoft.com> * Remove AzdataSession from azdata commands (#14856) * remove session * Add in controller-context support * Revert "Add in controller-context support" This reverts commit 3b39b968efbf6054041cb01cb2d8443532643a82. * Add azdataContext to login * Undo book change * Undo change correctly * Add controller context support (#14862) * remove session * Add in controller-context support * Add params to fake * Fix tests * Add info and placeholder for controller URL/name (#14887) * Add info and placeholder for controller URL * add period + update name * update memento and allow editing of namespace/URL * vBump * vBump * Fix tests Co-authored-by: nasc17 <69922333+nasc17@users.noreply.github.com> Co-authored-by: Brian Bergeron <brian.e.bergeron@gmail.com> Co-authored-by: Brian Bergeron <brberger@microsoft.com> Co-authored-by: nasc17 <69922333+nasc17@users.noreply.github.com> Co-authored-by: Brian Bergeron <brian.e.bergeron@gmail.com> Co-authored-by: Brian Bergeron <brberger@microsoft.com>
63 lines
2.3 KiB
TypeScript
63 lines
2.3 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import 'mocha';
|
|
import * as path from 'path';
|
|
import * as sinon from 'sinon';
|
|
import * as yamljs from 'yamljs';
|
|
import { getDefaultKubeConfigPath, getKubeConfigClusterContexts, KubeClusterContext } from '../../common/kubeUtils';
|
|
import { tryExecuteAction } from '../../common/utils';
|
|
|
|
const kubeConfig =
|
|
{
|
|
'contexts': [
|
|
{
|
|
'context': {
|
|
'cluster': 'docker-desktop',
|
|
'user': 'docker-desktop'
|
|
},
|
|
'name': 'docker-for-desktop'
|
|
},
|
|
{
|
|
'context': {
|
|
'cluster': 'kubernetes',
|
|
'user': 'kubernetes-admin'
|
|
},
|
|
'name': 'kubernetes-admin@kubernetes'
|
|
}
|
|
],
|
|
'current-context': 'docker-for-desktop'
|
|
};
|
|
describe('KubeUtils', function (): void {
|
|
const configFile = 'kubeConfig';
|
|
|
|
afterEach('KubeUtils cleanup', () => {
|
|
sinon.restore();
|
|
});
|
|
|
|
it('getDefaultKubeConfigPath', async () => {
|
|
getDefaultKubeConfigPath().should.endWith(path.join('.kube', 'config'));
|
|
});
|
|
|
|
describe('get Kube Config Cluster Contexts', () => {
|
|
it('success', async () => {
|
|
sinon.stub(yamljs, 'load').returns(<any>kubeConfig);
|
|
const verifyContexts = (contexts: KubeClusterContext[], testName: string) => {
|
|
contexts.length.should.equal(2, `test: ${testName} failed`);
|
|
contexts[0].name.should.equal('docker-for-desktop', `test: ${testName} failed`);
|
|
contexts[0].isCurrentContext.should.be.true(`test: ${testName} failed`);
|
|
contexts[1].name.should.equal('kubernetes-admin@kubernetes', `test: ${testName} failed`);
|
|
contexts[1].isCurrentContext.should.be.false(`test: ${testName} failed`);
|
|
};
|
|
verifyContexts(getKubeConfigClusterContexts(configFile), 'getKubeConfigClusterContexts');
|
|
});
|
|
it('throws error when unable to load config file', async () => {
|
|
const error = new Error('unknown error accessing file');
|
|
sinon.stub(yamljs, 'load').throws(error); // simulate an error thrown from config file load
|
|
((await tryExecuteAction(() => getKubeConfigClusterContexts(configFile))).error).should.equal(error, `test: getKubeConfigClusterContexts failed`);
|
|
});
|
|
});
|
|
});
|