mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix use of bundled kubectl (#241)
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
758034f61a
commit
d80e956870
14
__mocks__/electron.js
Normal file
14
__mocks__/electron.js
Normal file
@ -0,0 +1,14 @@
|
||||
module.exports = {
|
||||
require: jest.fn(),
|
||||
match: jest.fn(),
|
||||
app: {
|
||||
getVersion: jest.fn().mockReturnValue("3.0.0"),
|
||||
getPath: jest.fn().mockReturnValue("/foo/bar")
|
||||
},
|
||||
remote: {
|
||||
app: {
|
||||
getPath: jest.fn()
|
||||
}
|
||||
},
|
||||
dialog: jest.fn()
|
||||
};
|
||||
@ -11,7 +11,7 @@
|
||||
"version": "3.2.0",
|
||||
"main": "main.ts",
|
||||
"config": {
|
||||
"bundledKubectlVersion": "1.17.3",
|
||||
"bundledKubectlVersion": "1.17.4",
|
||||
"bundledHelmVersion": "3.1.2"
|
||||
},
|
||||
"engines": {
|
||||
@ -99,6 +99,7 @@
|
||||
"collectCoverage": true,
|
||||
"testRegex": "spec/.*_(spec)\\.[jt]sx?$",
|
||||
"verbose": true,
|
||||
"testEnvironment": "node",
|
||||
"transform": {
|
||||
"^.+\\.tsx?$": "ts-jest"
|
||||
}
|
||||
|
||||
17
spec/src/main/kubectl_spec.ts
Normal file
17
spec/src/main/kubectl_spec.ts
Normal file
@ -0,0 +1,17 @@
|
||||
jest.mock("electron")
|
||||
jest.mock("../../../src/common/user-store")
|
||||
|
||||
import { Kubectl, bundledKubectl } from "../../../src/main/kubectl"
|
||||
|
||||
describe("kubectlVersion", () => {
|
||||
|
||||
it("returns bundled version if exactly same version used", async () => {
|
||||
const kubectl = new Kubectl(bundledKubectl.kubectlVersion)
|
||||
expect(kubectl.kubectlVersion).toBe(bundledKubectl.kubectlVersion)
|
||||
})
|
||||
|
||||
it("returns bundled version if same major.minor version is used", async () => {
|
||||
const kubectl = new Kubectl("1.17.0")
|
||||
expect(kubectl.kubectlVersion).toBe(bundledKubectl.kubectlVersion)
|
||||
})
|
||||
})
|
||||
9
src/common/__mocks__/user-store.ts
Normal file
9
src/common/__mocks__/user-store.ts
Normal file
@ -0,0 +1,9 @@
|
||||
const userStore = {
|
||||
getPreferences: jest.fn(() => {
|
||||
return {
|
||||
downloadMirror: "default"
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export { userStore };
|
||||
@ -11,6 +11,7 @@ import * as lockFile from "proper-lockfile"
|
||||
import { helmCli } from "./helm-cli"
|
||||
import { userStore } from "../common/user-store"
|
||||
|
||||
const bundledVersion = require("../../package.json").config.bundledKubectlVersion
|
||||
const kubectlMap: Map<string, string> = new Map([
|
||||
["1.7", "1.8.15"],
|
||||
["1.8", "1.9.10"],
|
||||
@ -22,7 +23,7 @@ const kubectlMap: Map<string, string> = new Map([
|
||||
["1.14", "1.14.10"],
|
||||
["1.15", "1.15.11"],
|
||||
["1.16", "1.16.8"],
|
||||
["1.17", "1.17.4"],
|
||||
["1.17", bundledVersion],
|
||||
["1.18", "1.18.0"]
|
||||
])
|
||||
|
||||
@ -54,7 +55,7 @@ export class Kubectl {
|
||||
|
||||
public static readonly kubectlDir = path.join((app || remote.app).getPath("userData"), "binaries", "kubectl")
|
||||
public static readonly bundledKubectlPath = bundledPath
|
||||
public static readonly bundledKubectlVersion: string = require("../../package.json").config.bundledKubectlVersion
|
||||
public static readonly bundledKubectlVersion: string = bundledVersion
|
||||
private static bundledInstance: Kubectl;
|
||||
|
||||
// Returns the single bundled Kubectl instance
|
||||
|
||||
Loading…
Reference in New Issue
Block a user