mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Consolidate naming for running setups
Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
parent
cf87bc14d9
commit
d5ab2ab000
@ -24,7 +24,7 @@ import directoryForUserDataInjectable from "../app-paths/directory-for-user-data
|
|||||||
import { getDiForUnitTesting } from "../../main/getDiForUnitTesting";
|
import { getDiForUnitTesting } from "../../main/getDiForUnitTesting";
|
||||||
import getConfigurationFileModelInjectable from "../get-configuration-file-model/get-configuration-file-model.injectable";
|
import getConfigurationFileModelInjectable from "../get-configuration-file-model/get-configuration-file-model.injectable";
|
||||||
import appVersionInjectable from "../get-configuration-file-model/app-version/app-version.injectable";
|
import appVersionInjectable from "../get-configuration-file-model/app-version/app-version.injectable";
|
||||||
import { runSetupables } from "../setupable-injection-token/run-setupables";
|
import { runSetups } from "../setupable-injection-token/run-setups";
|
||||||
|
|
||||||
console = new Console(stdout, stderr);
|
console = new Console(stdout, stderr);
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ describe("cluster-store", () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
mainDi = getDiForUnitTesting({ doGeneralOverrides: true });
|
mainDi = getDiForUnitTesting({ doGeneralOverrides: true });
|
||||||
|
|
||||||
await runSetupables(mainDi);
|
await runSetups(mainDi);
|
||||||
|
|
||||||
mockFs();
|
mockFs();
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import type { DiContainer } from "@ogre-tools/injectable";
|
|||||||
import hotbarStoreInjectable from "../hotbar-store.injectable";
|
import hotbarStoreInjectable from "../hotbar-store.injectable";
|
||||||
import { HotbarStore } from "../hotbar-store";
|
import { HotbarStore } from "../hotbar-store";
|
||||||
import catalogCatalogEntityInjectable from "../catalog-entities/general-catalog-entities/implementations/catalog-catalog-entity.injectable";
|
import catalogCatalogEntityInjectable from "../catalog-entities/general-catalog-entities/implementations/catalog-catalog-entity.injectable";
|
||||||
import { runSetupables } from "../setupable-injection-token/run-setupables";
|
import { runSetups } from "../setupable-injection-token/run-setups";
|
||||||
|
|
||||||
jest.mock("../../main/catalog/catalog-entity-registry", () => ({
|
jest.mock("../../main/catalog/catalog-entity-registry", () => ({
|
||||||
catalogEntityRegistry: {
|
catalogEntityRegistry: {
|
||||||
@ -151,7 +151,7 @@ describe("HotbarStore", () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
mockFs();
|
mockFs();
|
||||||
|
|
||||||
await runSetupables(di);
|
await runSetups(di);
|
||||||
|
|
||||||
hotbarStore = di.inject(hotbarStoreInjectable);
|
hotbarStore = di.inject(hotbarStoreInjectable);
|
||||||
});
|
});
|
||||||
@ -382,7 +382,7 @@ describe("HotbarStore", () => {
|
|||||||
|
|
||||||
mockFs(configurationToBeMigrated);
|
mockFs(configurationToBeMigrated);
|
||||||
|
|
||||||
await runSetupables(di);
|
await runSetups(di);
|
||||||
|
|
||||||
hotbarStore = di.inject(hotbarStoreInjectable);
|
hotbarStore = di.inject(hotbarStoreInjectable);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -5,10 +5,10 @@
|
|||||||
import type { DiContainer } from "@ogre-tools/injectable";
|
import type { DiContainer } from "@ogre-tools/injectable";
|
||||||
import { setupableInjectionToken } from "./setupable-injection-token";
|
import { setupableInjectionToken } from "./setupable-injection-token";
|
||||||
|
|
||||||
export const runSetupables = async (di: DiContainer) => {
|
export const runSetups = async (di: DiContainer) => {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
di
|
di
|
||||||
.injectMany(setupableInjectionToken)
|
.injectMany(setupableInjectionToken)
|
||||||
.map((setupable) => setupable.doSetup()),
|
.map((setupable) => setupable.runSetup()),
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@ -5,7 +5,7 @@
|
|||||||
import { getInjectionToken } from "@ogre-tools/injectable";
|
import { getInjectionToken } from "@ogre-tools/injectable";
|
||||||
|
|
||||||
export interface Setupable {
|
export interface Setupable {
|
||||||
doSetup: () => Promise<void> | void;
|
runSetup: () => Promise<void> | void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const setupableInjectionToken = getInjectionToken<Setupable>({
|
export const setupableInjectionToken = getInjectionToken<Setupable>({
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { runSetupables } from "../../common/setupable-injection-token/run-setupables";
|
import { runSetups } from "../../common/setupable-injection-token/run-setups";
|
||||||
|
|
||||||
const logger = {
|
const logger = {
|
||||||
silly: jest.fn(),
|
silly: jest.fn(),
|
||||||
@ -86,7 +86,7 @@ describe("create clusters", () => {
|
|||||||
throw new Error("you should never come here");
|
throw new Error("you should never come here");
|
||||||
});
|
});
|
||||||
|
|
||||||
await runSetupables(di);
|
await runSetups(di);
|
||||||
|
|
||||||
createCluster = di.inject(createClusterInjectionToken);
|
createCluster = di.inject(createClusterInjectionToken);
|
||||||
|
|
||||||
|
|||||||
@ -57,7 +57,7 @@ import path from "path";
|
|||||||
import spawnInjectable from "../child-process/spawn.injectable";
|
import spawnInjectable from "../child-process/spawn.injectable";
|
||||||
import getConfigurationFileModelInjectable from "../../common/get-configuration-file-model/get-configuration-file-model.injectable";
|
import getConfigurationFileModelInjectable from "../../common/get-configuration-file-model/get-configuration-file-model.injectable";
|
||||||
import appVersionInjectable from "../../common/get-configuration-file-model/app-version/app-version.injectable";
|
import appVersionInjectable from "../../common/get-configuration-file-model/app-version/app-version.injectable";
|
||||||
import { runSetupables } from "../../common/setupable-injection-token/run-setupables";
|
import { runSetups } from "../../common/setupable-injection-token/run-setups";
|
||||||
|
|
||||||
console = new Console(stdout, stderr);
|
console = new Console(stdout, stderr);
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ describe("kube auth proxy tests", () => {
|
|||||||
|
|
||||||
mockFs(mockMinikubeConfig);
|
mockFs(mockMinikubeConfig);
|
||||||
|
|
||||||
await runSetupables(di);
|
await runSetups(di);
|
||||||
|
|
||||||
createCluster = di.inject(createClusterInjectionToken);
|
createCluster = di.inject(createClusterInjectionToken);
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { runSetupables } from "../../common/setupable-injection-token/run-setupables";
|
import { runSetups } from "../../common/setupable-injection-token/run-setups";
|
||||||
|
|
||||||
const logger = {
|
const logger = {
|
||||||
silly: jest.fn(),
|
silly: jest.fn(),
|
||||||
@ -86,7 +86,7 @@ describe("kubeconfig manager tests", () => {
|
|||||||
throw new Error("you should never come here");
|
throw new Error("you should never come here");
|
||||||
});
|
});
|
||||||
|
|
||||||
await runSetupables(di);
|
await runSetups(di);
|
||||||
|
|
||||||
const createCluster = di.inject(createClusterInjectionToken);
|
const createCluster = di.inject(createClusterInjectionToken);
|
||||||
|
|
||||||
|
|||||||
@ -31,7 +31,7 @@ const setupAppPathsInjectable = getInjectable({
|
|||||||
const joinPaths = di.inject(joinPathsInjectable);
|
const joinPaths = di.inject(joinPathsInjectable);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
doSetup: () => {
|
runSetup: () => {
|
||||||
if (directoryForIntegrationTesting) {
|
if (directoryForIntegrationTesting) {
|
||||||
setElectronAppPath("appData", directoryForIntegrationTesting);
|
setElectronAppPath("appData", directoryForIntegrationTesting);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,7 +18,7 @@ import directoryForKubeConfigsInjectable from "../../../common/app-paths/directo
|
|||||||
import { ClusterStore } from "../../../common/cluster-store/cluster-store";
|
import { ClusterStore } from "../../../common/cluster-store/cluster-store";
|
||||||
import getConfigurationFileModelInjectable from "../../../common/get-configuration-file-model/get-configuration-file-model.injectable";
|
import getConfigurationFileModelInjectable from "../../../common/get-configuration-file-model/get-configuration-file-model.injectable";
|
||||||
import appVersionInjectable from "../../../common/get-configuration-file-model/app-version/app-version.injectable";
|
import appVersionInjectable from "../../../common/get-configuration-file-model/app-version/app-version.injectable";
|
||||||
import { runSetupables } from "../../../common/setupable-injection-token/run-setupables";
|
import { runSetups } from "../../../common/setupable-injection-token/run-setups";
|
||||||
|
|
||||||
jest.mock("electron", () => ({
|
jest.mock("electron", () => ({
|
||||||
app: {
|
app: {
|
||||||
@ -48,7 +48,7 @@ describe("kubeconfig-sync.source tests", () => {
|
|||||||
ClusterStore.createInstance({ createCluster: () => null }),
|
ClusterStore.createInstance({ createCluster: () => null }),
|
||||||
);
|
);
|
||||||
|
|
||||||
await runSetupables(di);
|
await runSetups(di);
|
||||||
|
|
||||||
computeDiff = computeDiffFor({
|
computeDiff = computeDiffFor({
|
||||||
directoryForKubeConfigs: di.inject(directoryForKubeConfigsInjectable),
|
directoryForKubeConfigs: di.inject(directoryForKubeConfigsInjectable),
|
||||||
|
|||||||
@ -18,7 +18,7 @@ import lensProtocolRouterMainInjectable from "../lens-protocol-router-main/lens-
|
|||||||
import extensionsStoreInjectable from "../../../extensions/extensions-store/extensions-store.injectable";
|
import extensionsStoreInjectable from "../../../extensions/extensions-store/extensions-store.injectable";
|
||||||
import getConfigurationFileModelInjectable from "../../../common/get-configuration-file-model/get-configuration-file-model.injectable";
|
import getConfigurationFileModelInjectable from "../../../common/get-configuration-file-model/get-configuration-file-model.injectable";
|
||||||
import appVersionInjectable from "../../../common/get-configuration-file-model/app-version/app-version.injectable";
|
import appVersionInjectable from "../../../common/get-configuration-file-model/app-version/app-version.injectable";
|
||||||
import { runSetupables } from "../../../common/setupable-injection-token/run-setupables";
|
import { runSetups } from "../../../common/setupable-injection-token/run-setups";
|
||||||
|
|
||||||
jest.mock("../../../common/ipc");
|
jest.mock("../../../common/ipc");
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ describe("protocol router tests", () => {
|
|||||||
di.permitSideEffects(getConfigurationFileModelInjectable);
|
di.permitSideEffects(getConfigurationFileModelInjectable);
|
||||||
di.permitSideEffects(appVersionInjectable);
|
di.permitSideEffects(appVersionInjectable);
|
||||||
|
|
||||||
await runSetupables(di);
|
await runSetups(di);
|
||||||
|
|
||||||
extensionLoader = di.inject(extensionLoaderInjectable);
|
extensionLoader = di.inject(extensionLoaderInjectable);
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import asyncFn from "@async-fn/jest";
|
|||||||
import parseRequestInjectable from "./parse-request.injectable";
|
import parseRequestInjectable from "./parse-request.injectable";
|
||||||
import { contentTypes } from "./router-content-types";
|
import { contentTypes } from "./router-content-types";
|
||||||
import mockFs from "mock-fs";
|
import mockFs from "mock-fs";
|
||||||
import { runSetupables } from "../../common/setupable-injection-token/run-setupables";
|
import { runSetups } from "../../common/setupable-injection-token/run-setups";
|
||||||
|
|
||||||
describe("router", () => {
|
describe("router", () => {
|
||||||
let router: Router;
|
let router: Router;
|
||||||
@ -43,7 +43,7 @@ describe("router", () => {
|
|||||||
|
|
||||||
di.register(injectable);
|
di.register(injectable);
|
||||||
|
|
||||||
await runSetupables(di);
|
await runSetups(di);
|
||||||
|
|
||||||
router = di.inject(routerInjectable);
|
router = di.inject(routerInjectable);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -14,7 +14,7 @@ const setupAppPathsInjectable = getInjectable({
|
|||||||
id: "setup-app-paths",
|
id: "setup-app-paths",
|
||||||
|
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => ({
|
||||||
doSetup: async () => {
|
runSetup: async () => {
|
||||||
const getValueFromRegisteredChannel = di.inject(
|
const getValueFromRegisteredChannel = di.inject(
|
||||||
getValueFromRegisteredChannelInjectable,
|
getValueFromRegisteredChannelInjectable,
|
||||||
);
|
);
|
||||||
|
|||||||
@ -11,7 +11,7 @@ const registerIpcChannelListenersInjectable = getInjectable({
|
|||||||
id: "register-ipc-channel-listeners",
|
id: "register-ipc-channel-listeners",
|
||||||
|
|
||||||
instantiate: di => ({
|
instantiate: di => ({
|
||||||
doSetup: async () => {
|
runSetup: async () => {
|
||||||
const registerIpcChannelListener = di.inject(registerIpcChannelListenerInjectable);
|
const registerIpcChannelListener = di.inject(registerIpcChannelListenerInjectable);
|
||||||
|
|
||||||
const listeners = di.injectMany(ipcChannelListenerInjectionToken);
|
const listeners = di.injectMany(ipcChannelListenerInjectionToken);
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
import { getDiForUnitTesting as getRendererDi } from "../renderer/getDiForUnitTesting";
|
import { getDiForUnitTesting as getRendererDi } from "../renderer/getDiForUnitTesting";
|
||||||
import { getDiForUnitTesting as getMainDi } from "../main/getDiForUnitTesting";
|
import { getDiForUnitTesting as getMainDi } from "../main/getDiForUnitTesting";
|
||||||
import { overrideIpcBridge } from "./override-ipc-bridge";
|
import { overrideIpcBridge } from "./override-ipc-bridge";
|
||||||
import { runSetupables } from "../common/setupable-injection-token/run-setupables";
|
import { runSetups } from "../common/setupable-injection-token/run-setups";
|
||||||
|
|
||||||
export const getDisForUnitTesting = (
|
export const getDisForUnitTesting = (
|
||||||
{ doGeneralOverrides } = { doGeneralOverrides: false },
|
{ doGeneralOverrides } = { doGeneralOverrides: false },
|
||||||
@ -20,6 +20,6 @@ export const getDisForUnitTesting = (
|
|||||||
mainDi,
|
mainDi,
|
||||||
|
|
||||||
runSetups: () =>
|
runSetups: () =>
|
||||||
Promise.all([runSetupables(rendererDi), runSetupables(mainDi)]),
|
Promise.all([runSetups(rendererDi), runSetups(mainDi)]),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user