Skip to content

Commit

Permalink
[server] move workspace ide configuration to ide service
Browse files Browse the repository at this point in the history
Co-authored-by: Pudong Zheng <[email protected]>
Co-authored-by: Victor Nogueira <[email protected]>
Co-authored-by: Andrea Falzetti <[email protected]>
  • Loading branch information
4 people authored and roboquat committed Dec 7, 2022
1 parent 19e93c4 commit 9ea5ff3
Show file tree
Hide file tree
Showing 5 changed files with 457 additions and 453 deletions.
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

0 comments on commit 9ea5ff3

Please sign in to comment.