mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
remove old migration tests
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
91d2d61be4
commit
e8c7967824
@ -334,159 +334,6 @@ users:
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("pre 2.0 config with an existing cluster", () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
ClusterStore.resetInstance();
|
|
||||||
|
|
||||||
const mockOpts = {
|
|
||||||
"some-directory-for-user-data": {
|
|
||||||
"lens-cluster-store.json": JSON.stringify({
|
|
||||||
__internal__: {
|
|
||||||
migrations: {
|
|
||||||
version: "1.0.0",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
cluster1: minimalValidKubeConfig,
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
mockFs(mockOpts);
|
|
||||||
|
|
||||||
clusterStore = mainDi.inject(clusterStoreInjectable);
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
mockFs.restore();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("migrates to modern format with kubeconfig in a file", async () => {
|
|
||||||
const config = clusterStore.clustersList[0].kubeConfigPath;
|
|
||||||
|
|
||||||
expect(fs.readFileSync(config, "utf8")).toContain(`"contexts":[`);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("pre 2.6.0 config with a cluster that has arrays in auth config", () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
ClusterStore.resetInstance();
|
|
||||||
const mockOpts = {
|
|
||||||
"some-directory-for-user-data": {
|
|
||||||
"lens-cluster-store.json": JSON.stringify({
|
|
||||||
__internal__: {
|
|
||||||
migrations: {
|
|
||||||
version: "2.4.1",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
cluster1: {
|
|
||||||
kubeConfig: JSON.stringify({
|
|
||||||
apiVersion: "v1",
|
|
||||||
clusters: [
|
|
||||||
{
|
|
||||||
cluster: {
|
|
||||||
server: "https://10.211.55.6:8443",
|
|
||||||
},
|
|
||||||
name: "minikube",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
contexts: [
|
|
||||||
{
|
|
||||||
context: {
|
|
||||||
cluster: "minikube",
|
|
||||||
user: "minikube",
|
|
||||||
name: "minikube",
|
|
||||||
},
|
|
||||||
name: "minikube",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"current-context": "minikube",
|
|
||||||
kind: "Config",
|
|
||||||
preferences: {},
|
|
||||||
users: [
|
|
||||||
{
|
|
||||||
name: "minikube",
|
|
||||||
user: {
|
|
||||||
"client-certificate": "/Users/foo/.minikube/client.crt",
|
|
||||||
"client-key": "/Users/foo/.minikube/client.key",
|
|
||||||
"auth-provider": {
|
|
||||||
config: {
|
|
||||||
"access-token": ["should be string"],
|
|
||||||
expiry: ["should be string"],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
mockFs(mockOpts);
|
|
||||||
|
|
||||||
clusterStore = mainDi.inject(clusterStoreInjectable);
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
mockFs.restore();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("replaces array format access token and expiry into string", async () => {
|
|
||||||
const file = clusterStore.clustersList[0].kubeConfigPath;
|
|
||||||
const config = fs.readFileSync(file, "utf8");
|
|
||||||
const kc = yaml.load(config) as Record<string, any>;
|
|
||||||
|
|
||||||
expect(kc.users[0].user["auth-provider"].config["access-token"]).toBe(
|
|
||||||
"should be string",
|
|
||||||
);
|
|
||||||
expect(kc.users[0].user["auth-provider"].config["expiry"]).toBe(
|
|
||||||
"should be string",
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("pre 2.6.0 config with a cluster icon", () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
ClusterStore.resetInstance();
|
|
||||||
const mockOpts = {
|
|
||||||
"some-directory-for-user-data": {
|
|
||||||
"lens-cluster-store.json": JSON.stringify({
|
|
||||||
__internal__: {
|
|
||||||
migrations: {
|
|
||||||
version: "2.4.1",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
cluster1: {
|
|
||||||
kubeConfig: minimalValidKubeConfig,
|
|
||||||
icon: "icon_path",
|
|
||||||
preferences: {
|
|
||||||
terminalCWD: "/some-directory-for-user-data",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
icon_path: testDataIcon,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
mockFs(mockOpts);
|
|
||||||
|
|
||||||
clusterStore = mainDi.inject(clusterStoreInjectable);
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
mockFs.restore();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("moves the icon into preferences", async () => {
|
|
||||||
const storedClusterData = clusterStore.clustersList[0];
|
|
||||||
|
|
||||||
expect(Object.prototype.hasOwnProperty.call(storedClusterData, "icon")).toBe(false);
|
|
||||||
expect(Object.prototype.hasOwnProperty.call(storedClusterData.preferences, "icon")).toBe(true);
|
|
||||||
expect(storedClusterData.preferences.icon.startsWith("data:;base64,")).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("pre 3.6.0-beta.1 config with an existing cluster", () => {
|
describe("pre 3.6.0-beta.1 config with an existing cluster", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
ClusterStore.resetInstance();
|
ClusterStore.resetInstance();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user