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:
parent
8c3d7d94fb
commit
55ce80ea3f
@ -31,14 +31,8 @@ jest.mock("request-promise-native");
|
|||||||
import { Console } from "console";
|
import { Console } from "console";
|
||||||
import mockFs from "mock-fs";
|
import mockFs from "mock-fs";
|
||||||
import { Cluster } from "../cluster";
|
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";
|
import { Kubectl } from "../kubectl";
|
||||||
|
|
||||||
const mockedRequest = request as jest.MockedFunction<typeof request>;
|
|
||||||
|
|
||||||
console = new Console(process.stdout, process.stderr); // fix mockFS
|
console = new Console(process.stdout, process.stderr); // fix mockFS
|
||||||
|
|
||||||
describe("create clusters", () => {
|
describe("create clusters", () => {
|
||||||
|
|||||||
@ -31,10 +31,14 @@ import fse from "fs-extra";
|
|||||||
import { loadYaml } from "@kubernetes/client-node";
|
import { loadYaml } from "@kubernetes/client-node";
|
||||||
import { Console } from "console";
|
import { Console } from "console";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
|
import { LensProxy } from "../proxy/lens-proxy";
|
||||||
|
|
||||||
console = new Console(process.stdout, process.stderr); // fix mockFS
|
console = new Console(process.stdout, process.stderr); // fix mockFS
|
||||||
|
|
||||||
describe("kubeconfig manager tests", () => {
|
describe("kubeconfig manager tests", () => {
|
||||||
|
let cluster: Cluster;
|
||||||
|
let contextHandler: ContextHandler;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
const mockOpts = {
|
const mockOpts = {
|
||||||
"minikube-config.yml": JSON.stringify({
|
"minikube-config.yml": JSON.stringify({
|
||||||
@ -61,6 +65,14 @@ describe("kubeconfig manager tests", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
mockFs(mockOpts);
|
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(() => {
|
afterEach(() => {
|
||||||
@ -68,12 +80,6 @@ describe("kubeconfig manager tests", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should create 'temp' kube config with proxy", async () => {
|
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);
|
const kubeConfManager = new KubeconfigManager(cluster, contextHandler);
|
||||||
|
|
||||||
expect(logger.error).not.toBeCalled();
|
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 () => {
|
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 kubeConfManager = new KubeconfigManager(cluster, contextHandler);
|
||||||
const configPath = await kubeConfManager.getPath();
|
const configPath = await kubeConfManager.getPath();
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user