From c23d3e349bff41089d8f3a378e4b0683d6f4e402 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Mon, 5 Dec 2022 16:20:49 -0500 Subject: [PATCH] Fix cluster store tests Signed-off-by: Sebastian Malton --- src/common/__tests__/cluster-store.test.ts | 38 +++++++++------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/src/common/__tests__/cluster-store.test.ts b/src/common/__tests__/cluster-store.test.ts index b799d687c7..28357ae5ff 100644 --- a/src/common/__tests__/cluster-store.test.ts +++ b/src/common/__tests__/cluster-store.test.ts @@ -93,10 +93,9 @@ describe("cluster-store", () => { mainDi.override(normalizedPlatformInjectable, () => "darwin"); mainDi.permitSideEffects(getConfigurationFileModelInjectable); - mainDi.permitSideEffects(clusterStoreInjectable); - mainDi.permitSideEffects(fsInjectable); + mainDi.unoverride(getConfigurationFileModelInjectable); - mainDi.unoverride(clusterStoreInjectable); + mainDi.permitSideEffects(fsInjectable); }); afterEach(() => { @@ -107,21 +106,19 @@ describe("cluster-store", () => { let getCustomKubeConfigDirectory: (directoryName: string) => string; beforeEach(async () => { - getCustomKubeConfigDirectory = mainDi.inject( - getCustomKubeConfigDirectoryInjectable, - ); + getCustomKubeConfigDirectory = mainDi.inject(getCustomKubeConfigDirectoryInjectable); - const mockOpts = { + mockFs({ "some-directory-for-user-data": { "lens-cluster-store.json": JSON.stringify({}), }, - }; - - mockFs(mockOpts); + }); createCluster = mainDi.inject(createClusterInjectionToken); clusterStore = mainDi.inject(clusterStoreInjectable); + + clusterStore.load(); }); afterEach(() => { @@ -205,7 +202,7 @@ describe("cluster-store", () => { describe("config with existing clusters", () => { beforeEach(() => { - const mockOpts = { + mockFs({ "temp-kube-config": kubeconfig, "some-directory-for-user-data": { "lens-cluster-store.json": JSON.stringify({ @@ -239,13 +236,12 @@ describe("cluster-store", () => { ], }), }, - }; - - mockFs(mockOpts); + }); createCluster = mainDi.inject(createClusterInjectionToken); clusterStore = mainDi.inject(clusterStoreInjectable); + clusterStore.load(); }); afterEach(() => { @@ -295,7 +291,7 @@ users: token: kubeconfig-user-q4lm4:xxxyyyy `; - const mockOpts = { + mockFs({ "invalid-kube-config": invalidKubeconfig, "valid-kube-config": kubeconfig, "some-directory-for-user-data": { @@ -323,13 +319,12 @@ users: ], }), }, - }; - - mockFs(mockOpts); + }); createCluster = mainDi.inject(createClusterInjectionToken); clusterStore = mainDi.inject(clusterStoreInjectable); + clusterStore.load(); }); afterEach(() => { @@ -345,7 +340,7 @@ users: describe("pre 3.6.0-beta.1 config with an existing cluster", () => { beforeEach(() => { - const mockOpts = { + mockFs({ "some-directory-for-user-data": { "lens-cluster-store.json": JSON.stringify({ __internal__: { @@ -366,15 +361,14 @@ users: }), icon_path: testDataIcon, }, - }; - - mockFs(mockOpts); + }); mainDi.override(storeMigrationVersionInjectable, () => "3.6.0"); createCluster = mainDi.inject(createClusterInjectionToken); clusterStore = mainDi.inject(clusterStoreInjectable); + clusterStore.load(); }); afterEach(() => {