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

fix tests

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen 2021-05-04 15:21:47 +03:00
parent 8c3d7d94fb
commit 55ce80ea3f
2 changed files with 12 additions and 18 deletions

View File

@ -31,14 +31,8 @@ jest.mock("request-promise-native");
import { Console } from "console";
import mockFs from "mock-fs";
import { Cluster } from "../cluster";
import { ContextHandler } from "../context-handler";
import { V1ResourceAttributes } from "@kubernetes/client-node";
import { apiResources } from "../../common/rbac";
import request from "request-promise-native";
import { Kubectl } from "../kubectl";
const mockedRequest = request as jest.MockedFunction<typeof request>;
console = new Console(process.stdout, process.stderr); // fix mockFS
describe("create clusters", () => {

View File

@ -31,10 +31,14 @@ import fse from "fs-extra";
import { loadYaml } from "@kubernetes/client-node";
import { Console } from "console";
import * as path from "path";
import { LensProxy } from "../proxy/lens-proxy";
console = new Console(process.stdout, process.stderr); // fix mockFS
describe("kubeconfig manager tests", () => {
let cluster: Cluster;
let contextHandler: ContextHandler;
beforeEach(() => {
const mockOpts = {
"minikube-config.yml": JSON.stringify({
@ -61,6 +65,14 @@ describe("kubeconfig manager tests", () => {
};
mockFs(mockOpts);
cluster = new Cluster({
id: "foo",
contextName: "minikube",
kubeConfigPath: "minikube-config.yml",
});
contextHandler = jest.fn() as any;
jest.spyOn(KubeconfigManager.prototype, "resolveProxyUrl", "get").mockReturnValue("http://127.0.0.1:9191/foo");
});
afterEach(() => {
@ -68,12 +80,6 @@ describe("kubeconfig manager tests", () => {
});
it("should create 'temp' kube config with proxy", async () => {
const cluster = new Cluster({
id: "foo",
contextName: "minikube",
kubeConfigPath: "minikube-config.yml",
});
const contextHandler = new ContextHandler(cluster);
const kubeConfManager = new KubeconfigManager(cluster, contextHandler);
expect(logger.error).not.toBeCalled();
@ -89,12 +95,6 @@ describe("kubeconfig manager tests", () => {
});
it("should remove 'temp' kube config on unlink and remove reference from inside class", async () => {
const cluster = new Cluster({
id: "foo",
contextName: "minikube",
kubeConfigPath: "minikube-config.yml",
});
const contextHandler = new ContextHandler(cluster);
const kubeConfManager = new KubeconfigManager(cluster, contextHandler);
const configPath = await kubeConfManager.getPath();