Skip to content

Commit

Permalink
Improve loadFromCluster testing
Browse files Browse the repository at this point in the history
  • Loading branch information
brendandburns committed Jan 31, 2025
1 parent d53ff24 commit 827c2b7
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/config_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,29 @@ describe('KubeConfig', () => {
});
});

describe('loadFromCluster', () => {
it('should load from cluster', () => {
process.env.KUBERNETES_SERVICE_HOST = 'example.com';
process.env.KUBERNETES_SERVICE_PORT = '8080';

const kc = new KubeConfig();
kc.loadFromCluster();
const expectedCluster = {
caFile: '/var/run/secrets/kubernetes.io/serviceaccount/ca.crt',
name: 'inCluster',
server: 'http://example.com:8080',
skipTLSVerify: false,
};

process.env.KUBERNETES_SERVICE_HOST = undefined;
process.env.KUBERNETES_SERVICE_PORT = undefined;

strictEqual(kc.getCurrentContext(), 'inClusterContext');
deepEqual(kc.getCurrentCluster(), expectedCluster);
deepEqual(kc.getCluster(kc.getContextObject(kc.getCurrentContext())!.cluster), expectedCluster);
});
});

describe('loadFromClusterAndUser', () => {
it('should load from cluster and user', () => {
const kc = new KubeConfig();
Expand Down

0 comments on commit 827c2b7

Please sign in to comment.