From 642e41fe00a053e51fb6536c07ba7a8de5a249b4 Mon Sep 17 00:00:00 2001 From: Roman Kuznetsov Date: Mon, 2 Dec 2024 16:32:29 +0300 Subject: [PATCH] fix: just log warning if ubuntu version is not supported --- src/browser-installer/ubuntu-packages/apt.ts | 6 ++++++ .../ubuntu-packages/index.ts | 9 +++++++-- test/src/browser-installer/ubuntu-packages.ts | 20 ++++++++++++++++++- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/browser-installer/ubuntu-packages/apt.ts b/src/browser-installer/ubuntu-packages/apt.ts index a957c44a..88ae9b07 100644 --- a/src/browser-installer/ubuntu-packages/apt.ts +++ b/src/browser-installer/ubuntu-packages/apt.ts @@ -115,6 +115,12 @@ const unpackUbuntuPackages = async (packagesDir: string, destination: string): P }; export const installUbuntuPackages = async (packages: string[], destination: string): Promise => { + if (!packages) { + browserInstallerDebug(`There are no ubuntu packages to install`); + + return fs.ensureDir(destination); + } + const withRecursiveDependencies = await resolveTransitiveDependencies(packages); browserInstallerDebug(`Resolved direct packages to ${withRecursiveDependencies.length} dependencies`); diff --git a/src/browser-installer/ubuntu-packages/index.ts b/src/browser-installer/ubuntu-packages/index.ts index 8d64aa62..c2c0d1bd 100644 --- a/src/browser-installer/ubuntu-packages/index.ts +++ b/src/browser-installer/ubuntu-packages/index.ts @@ -16,9 +16,14 @@ const readUbuntuPackageDependencies = async (ubuntuMilestone: string): Promise { let fsStub: Record; let loggerLogStub: SinonStub; + let loggerWarnStub: SinonStub; let installUbuntuPackagesStub: SinonStub; let getUbuntuMilestoneStub: SinonStub; @@ -28,6 +29,7 @@ describe("browser-installer/ubuntu-packages", () => { } as Record; loggerLogStub = sandbox.stub(); + loggerWarnStub = sandbox.stub(); installUbuntuPackagesStub = sandbox.stub(); getUbuntuMilestoneStub = sandbox.stub().resolves("20"); @@ -35,7 +37,7 @@ describe("browser-installer/ubuntu-packages", () => { "fs-extra": fsStub, "./apt": { installUbuntuPackages: installUbuntuPackagesStub }, "./utils": { getUbuntuMilestone: getUbuntuMilestoneStub }, - "../../utils/logger": { log: loggerLogStub }, + "../../utils/logger": { log: loggerLogStub, warn: loggerWarnStub }, }); ({ writeUbuntuPackageDependencies, installUbuntuPackageDependencies, getUbuntuLinkerEnv } = ubuntuPackages); @@ -97,6 +99,22 @@ describe("browser-installer/ubuntu-packages", () => { assert.notCalled(loggerLogStub); assert.notCalled(installUbuntuPackagesStub); }); + + it("should log warning if current ubuntu version is not supported", async () => { + getUbuntuMilestoneStub.resolves("100500"); + fsStub.readJSON.withArgs(sinon.match("ubuntu-100500-dependencies.json")).rejects(new Error("No such file")); + + await installUbuntuPackageDependencies(); + + assert.calledOnceWith( + loggerWarnStub, + [ + `Unable to read ubuntu dependencies for Ubuntu@100500, as this version currently not supported`, + `Assuming all necessary packages are installed already`, + ].join("\n"), + ); + assert.calledOnceWith(installUbuntuPackagesStub, []); + }); }); describe("getUbuntuLinkerEnv", () => {