Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Server] Extract IDE config resolution logic to ide-service #15062

Merged
merged 1 commit into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions components/gitpod-protocol/src/workspace-instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,16 @@ export interface WorkspaceInstanceConfiguration {
// ideImage is the ref of the IDE image this instance uses.
ideImage: string;

// ideImageLayers are images needed for the ide to run,
// including ide-desktop, desktop-plugin and so on
ideImageLayers?: string[];

// desktopIdeImage is the ref of the desktop IDE image this instance uses.
// @deprected: replaced with the ideImageLayers field
desktopIdeImage?: string;

// desktopIdePluginImage is the ref of the desktop IDE plugin image this instance uses.
// @deprected: replaced with the desktopIdePluginImage field
desktopIdePluginImage?: string;

// supervisorImage is the ref of the supervisor image this instance uses.
Expand Down
154 changes: 154 additions & 0 deletions components/server/src/ide-service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
/**
* Copyright (c) 2020 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License-AGPL.txt in the project root for license information.
*/

import { User } from "@gitpod/gitpod-protocol";
import * as chai from "chai";
import { IDEService } from "./ide-service";
const expect = chai.expect;

describe("ide-service", function () {
describe("migrateSettings", function () {
const ideService = new IDEService();
it("with no ideSettings should be undefined", function () {
const user: User = {
id: "string",

creationDate: "string",
identities: [],
additionalData: {},
};
const result = ideService.migrateSettings(user);
expect(result).to.undefined;
});

it("with settingVersion 2.0 should be undefined", function () {
const user: User = {
id: "string",
creationDate: "string",
identities: [],
additionalData: {
ideSettings: {
settingVersion: "2.0",
defaultIde: "code-latest",
useDesktopIde: false,
},
},
};
const result = ideService.migrateSettings(user);
expect(result).to.undefined;
});

it("with code-latest should be code latest", function () {
const user: User = {
id: "string",
creationDate: "string",
identities: [],
additionalData: {
ideSettings: {
defaultIde: "code-latest",
useDesktopIde: false,
},
},
};
const result = ideService.migrateSettings(user);
expect(result?.defaultIde).to.equal("code");
expect(result?.useLatestVersion ?? false).to.be.true;
});

it("with code-desktop-insiders should be code-desktop latest", function () {
const user: User = {
id: "string",
creationDate: "string",
identities: [],
additionalData: {
ideSettings: {
defaultIde: "code",
defaultDesktopIde: "code-desktop-insiders",
useDesktopIde: true,
},
},
};
const result = ideService.migrateSettings(user);
expect(result?.defaultIde).to.equal("code-desktop");
expect(result?.useLatestVersion ?? false).to.be.true;
});

it("with code-desktop should be code-desktop", function () {
const user: User = {
id: "string",
creationDate: "string",
identities: [],
additionalData: {
ideSettings: {
defaultIde: "code",
defaultDesktopIde: "code-desktop",
useDesktopIde: true,
},
},
};
const result = ideService.migrateSettings(user);
expect(result?.defaultIde).to.equal("code-desktop");
expect(result?.useLatestVersion ?? false).to.be.false;
});

it("with intellij should be intellij", function () {
const user: User = {
id: "string",
creationDate: "string",
identities: [],
additionalData: {
ideSettings: {
defaultIde: "code",
defaultDesktopIde: "intellij",
useLatestVersion: false,
useDesktopIde: true,
},
},
};
const result = ideService.migrateSettings(user);
expect(result?.defaultIde).to.equal("intellij");
expect(result?.useLatestVersion ?? false).to.be.false;
});

it("with intellij latest version should be intellij latest", function () {
const user: User = {
id: "string",
creationDate: "string",
identities: [],
additionalData: {
ideSettings: {
defaultIde: "code",
defaultDesktopIde: "intellij",
useLatestVersion: true,
useDesktopIde: true,
},
},
};
const result = ideService.migrateSettings(user);
expect(result?.defaultIde).to.equal("intellij");
expect(result?.useLatestVersion ?? false).to.be.true;
});

it("with user desktopIde false should be code latest", function () {
const user: User = {
id: "string",
creationDate: "string",
identities: [],
additionalData: {
ideSettings: {
defaultIde: "code-latest",
defaultDesktopIde: "intellij",
useLatestVersion: false,
useDesktopIde: false,
},
},
};
const result = ideService.migrateSettings(user);
expect(result?.defaultIde).to.equal("code");
expect(result?.useLatestVersion ?? false).to.be.true;
});
});
});
Loading