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

Fix unit tests

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2021-07-06 16:35:06 -04:00
parent cedf82b1c2
commit c79bdbb42e
4 changed files with 40 additions and 58 deletions

View File

@ -1,25 +0,0 @@
{
"name": "kube-object-event-status",
"version": "0.1.0",
"description": "Adds kube object status from events",
"renderer": "dist/renderer.js",
"lens": {
"metadata": {},
"styles": []
},
"scripts": {
"build": "webpack && npm pack",
"dev": "webpack --watch",
"test": "echo NO TESTS"
},
"files": [
"dist/**/*"
],
"dependencies": {},
"devDependencies": {
"@k8slens/extensions": "file:../../src/extensions/npm/extensions",
"ts-loader": "^8.0.4",
"typescript": "^4.0.3",
"webpack": "^4.44.2"
}
}

View File

@ -148,8 +148,8 @@ export default {
store.set("hotbars", hotbars); store.set("hotbars", hotbars);
} catch (error) { } catch (error) {
if (!(error.code === "ENOENT" && error.path.endsWith("lens-workspace-store.json"))) { if (error.code !== "ENOENT") {
// ignore lens-workspace-store.json being missing // ignore files being missing
throw error; throw error;
} }
} }

View File

@ -30,8 +30,9 @@ import { MigrationDeclaration, migrationLog } from "../helpers";
export default { export default {
version: "5.0.3-beta.1", version: "5.0.3-beta.1",
run(store) { run(store) {
try {
const { syncKubeconfigEntries = [], ...preferences }: UserPreferencesModel = store.get("preferences") ?? {}; const { syncKubeconfigEntries = [], ...preferences }: UserPreferencesModel = store.get("preferences") ?? {};
const { clusters = [] }: ClusterStoreModel = readJsonSync(path.resolve(app.getPath("userData"), "lens-cluster-store.json")); const { clusters = [] }: ClusterStoreModel = readJsonSync(path.resolve(app.getPath("userData"), "lens-cluster-store.json")) ?? {};
const syncPaths = new Set(syncKubeconfigEntries.map(s => s.filePath)); const syncPaths = new Set(syncKubeconfigEntries.map(s => s.filePath));
syncPaths.add(path.join(os.homedir(), ".kube")); syncPaths.add(path.join(os.homedir(), ".kube"));
@ -62,5 +63,13 @@ export default {
migrationLog("Final list of synced paths", updatedSyncEntries); migrationLog("Final list of synced paths", updatedSyncEntries);
store.set("preferences", { ...preferences, syncKubeconfigEntries: updatedSyncEntries }); store.set("preferences", { ...preferences, syncKubeconfigEntries: updatedSyncEntries });
} catch (error) {
console.log(error);
if (error.code !== "ENOENT") {
// ignore files being missing
throw error;
}
}
}, },
} as MigrationDeclaration; } as MigrationDeclaration;

View File

@ -59,14 +59,7 @@ describe("Extensions", () => {
}); });
ExtensionInstallationStateStore.reset(); ExtensionInstallationStateStore.reset();
UserStore.resetInstance();
UserStore.createInstance();
ExtensionDiscovery.resetInstance();
ExtensionDiscovery.createInstance().uninstallExtension = jest.fn(() => Promise.resolve());
ExtensionLoader.resetInstance();
ExtensionLoader.createInstance().addExtension({ ExtensionLoader.createInstance().addExtension({
id: "extensionId", id: "extensionId",
manifest: { manifest: {
@ -79,10 +72,15 @@ describe("Extensions", () => {
isEnabled: true, isEnabled: true,
isCompatible: true isCompatible: true
}); });
ExtensionDiscovery.createInstance().uninstallExtension = jest.fn(() => Promise.resolve());
UserStore.createInstance();
}); });
afterEach(() => { afterEach(() => {
mockFs.restore(); mockFs.restore();
UserStore.resetInstance();
ExtensionDiscovery.resetInstance();
ExtensionLoader.resetInstance();
}); });
it("disables uninstall and disable buttons while uninstalling", async () => { it("disables uninstall and disable buttons while uninstalling", async () => {