1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Fix cluster store tests

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2022-12-05 16:20:49 -05:00
parent e414fbace5
commit c23d3e349b

View File

@ -93,10 +93,9 @@ describe("cluster-store", () => {
mainDi.override(normalizedPlatformInjectable, () => "darwin"); mainDi.override(normalizedPlatformInjectable, () => "darwin");
mainDi.permitSideEffects(getConfigurationFileModelInjectable); mainDi.permitSideEffects(getConfigurationFileModelInjectable);
mainDi.permitSideEffects(clusterStoreInjectable); mainDi.unoverride(getConfigurationFileModelInjectable);
mainDi.permitSideEffects(fsInjectable);
mainDi.unoverride(clusterStoreInjectable); mainDi.permitSideEffects(fsInjectable);
}); });
afterEach(() => { afterEach(() => {
@ -107,21 +106,19 @@ describe("cluster-store", () => {
let getCustomKubeConfigDirectory: (directoryName: string) => string; let getCustomKubeConfigDirectory: (directoryName: string) => string;
beforeEach(async () => { beforeEach(async () => {
getCustomKubeConfigDirectory = mainDi.inject( getCustomKubeConfigDirectory = mainDi.inject(getCustomKubeConfigDirectoryInjectable);
getCustomKubeConfigDirectoryInjectable,
);
const mockOpts = { mockFs({
"some-directory-for-user-data": { "some-directory-for-user-data": {
"lens-cluster-store.json": JSON.stringify({}), "lens-cluster-store.json": JSON.stringify({}),
}, },
}; });
mockFs(mockOpts);
createCluster = mainDi.inject(createClusterInjectionToken); createCluster = mainDi.inject(createClusterInjectionToken);
clusterStore = mainDi.inject(clusterStoreInjectable); clusterStore = mainDi.inject(clusterStoreInjectable);
clusterStore.load();
}); });
afterEach(() => { afterEach(() => {
@ -205,7 +202,7 @@ describe("cluster-store", () => {
describe("config with existing clusters", () => { describe("config with existing clusters", () => {
beforeEach(() => { beforeEach(() => {
const mockOpts = { mockFs({
"temp-kube-config": kubeconfig, "temp-kube-config": kubeconfig,
"some-directory-for-user-data": { "some-directory-for-user-data": {
"lens-cluster-store.json": JSON.stringify({ "lens-cluster-store.json": JSON.stringify({
@ -239,13 +236,12 @@ describe("cluster-store", () => {
], ],
}), }),
}, },
}; });
mockFs(mockOpts);
createCluster = mainDi.inject(createClusterInjectionToken); createCluster = mainDi.inject(createClusterInjectionToken);
clusterStore = mainDi.inject(clusterStoreInjectable); clusterStore = mainDi.inject(clusterStoreInjectable);
clusterStore.load();
}); });
afterEach(() => { afterEach(() => {
@ -295,7 +291,7 @@ users:
token: kubeconfig-user-q4lm4:xxxyyyy token: kubeconfig-user-q4lm4:xxxyyyy
`; `;
const mockOpts = { mockFs({
"invalid-kube-config": invalidKubeconfig, "invalid-kube-config": invalidKubeconfig,
"valid-kube-config": kubeconfig, "valid-kube-config": kubeconfig,
"some-directory-for-user-data": { "some-directory-for-user-data": {
@ -323,13 +319,12 @@ users:
], ],
}), }),
}, },
}; });
mockFs(mockOpts);
createCluster = mainDi.inject(createClusterInjectionToken); createCluster = mainDi.inject(createClusterInjectionToken);
clusterStore = mainDi.inject(clusterStoreInjectable); clusterStore = mainDi.inject(clusterStoreInjectable);
clusterStore.load();
}); });
afterEach(() => { afterEach(() => {
@ -345,7 +340,7 @@ users:
describe("pre 3.6.0-beta.1 config with an existing cluster", () => { describe("pre 3.6.0-beta.1 config with an existing cluster", () => {
beforeEach(() => { beforeEach(() => {
const mockOpts = { mockFs({
"some-directory-for-user-data": { "some-directory-for-user-data": {
"lens-cluster-store.json": JSON.stringify({ "lens-cluster-store.json": JSON.stringify({
__internal__: { __internal__: {
@ -366,15 +361,14 @@ users:
}), }),
icon_path: testDataIcon, icon_path: testDataIcon,
}, },
}; });
mockFs(mockOpts);
mainDi.override(storeMigrationVersionInjectable, () => "3.6.0"); mainDi.override(storeMigrationVersionInjectable, () => "3.6.0");
createCluster = mainDi.inject(createClusterInjectionToken); createCluster = mainDi.inject(createClusterInjectionToken);
clusterStore = mainDi.inject(clusterStoreInjectable); clusterStore = mainDi.inject(clusterStoreInjectable);
clusterStore.load();
}); });
afterEach(() => { afterEach(() => {