From 14382731794e6bf440804fc1adf077c442c2302a Mon Sep 17 00:00:00 2001 From: Lauri Nevala Date: Thu, 10 Sep 2020 13:02:01 +0300 Subject: [PATCH] Fix tests Signed-off-by: Lauri Nevala --- src/common/cluster-store_test.ts | 6 ++++++ src/main/cluster.ts | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/common/cluster-store_test.ts b/src/common/cluster-store_test.ts index 2810883690..d7d6df4d2a 100644 --- a/src/common/cluster-store_test.ts +++ b/src/common/cluster-store_test.ts @@ -31,6 +31,7 @@ describe("empty config", () => { it("adds new cluster to store", async () => { const cluster = new Cluster({ id: "foo", + contextName: "minikube", preferences: { terminalCWD: "/tmp", icon: "data:;base64,iVBORw0KGgoAAAANSUhEUgAAA1wAAAKoCAYAAABjkf5", @@ -54,6 +55,7 @@ describe("empty config", () => { it("check if store can contain multiple clusters", () => { const prodCluster = new Cluster({ id: "prod", + contextName: "prod", preferences: { clusterName: "prod" }, @@ -62,6 +64,7 @@ describe("empty config", () => { }); const devCluster = new Cluster({ id: "dev", + contextName: "dev", preferences: { clusterName: "dev" }, @@ -142,11 +145,13 @@ describe("config with existing clusters", () => { { id: 'cluster1', kubeConfig: 'foo', + contextName: 'foo', preferences: { terminalCWD: '/foo' } }, { id: 'cluster2', kubeConfig: 'foo2', + contextName: 'foo2', preferences: { terminalCWD: '/foo2' } } ] @@ -339,6 +344,7 @@ describe("pre 3.6.0-beta.1 config with an existing cluster", () => { { id: 'cluster1', kubeConfig: 'kubeconfig content', + contextName: 'cluster', preferences: { icon: "store://icon_path", } diff --git a/src/main/cluster.ts b/src/main/cluster.ts index a74153dea9..d160496cdf 100644 --- a/src/main/cluster.ts +++ b/src/main/cluster.ts @@ -78,7 +78,9 @@ export class Cluster implements ClusterModel { constructor(model: ClusterModel) { this.updateModel(model); const kubeconfig = this.getKubeconfig() - this.apiUrl = kubeconfig.getCluster(kubeconfig.getContextObject(this.contextName).cluster).server + if (kubeconfig.getContextObject(this.contextName)) { + this.apiUrl = kubeconfig.getCluster(kubeconfig.getContextObject(this.contextName).cluster).server + } } @action