Skip to content

Commit

Permalink
Change of test not darwin
Browse files Browse the repository at this point in the history
  • Loading branch information
ta-Hirose committed Sep 28, 2022
1 parent 8537edf commit 2df3a0f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 19 deletions.
4 changes: 4 additions & 0 deletions libs/deno_wrapper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { decompress } from "../deps.ts";
export default class DenoWrapper {
static build = {
os: Deno.build.os,
};
static zip = {
decompress: decompress,
};
}
4 changes: 2 additions & 2 deletions libs/postprocess/unzipper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Colors, decompress } from "../../deps.ts";
import { Colors } from "../../deps.ts";
import { BasePostprocess } from "./base_postprocess.ts";
import DenoWrapper from "../deno_wrapper.ts";

Expand All @@ -15,7 +15,7 @@ export class Unzipper extends BasePostprocess {
const rawOutput = await process.output();
Deno.stdout.write(rawOutput);
} else {
await decompress(targetPath, targetDir);
await DenoWrapper.zip.decompress(targetPath, targetDir);
}
return targetDir;
}
Expand Down
23 changes: 6 additions & 17 deletions tests/libs/actions.install.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,33 +434,22 @@ describe("InstallAction", () => {
}
});

it("check that the command for linux to extract the downloaded file is entered and recorded in dim.json and dim-lock.json.", async () => {
it("check that the decompress method is called with two arguments when the os is not darwin.", async () => {
createEmptyDimJson();
const kyGetStub = createKyGetStub("dummy");
const denoRunStub = stub(Deno, "run", () => ({
output: () => {},
status: () => Promise.resolve({ success: true }),
rid: 1,
} as Deno.Process));
const denoCloseStub = stub(Deno, "close");
const osStub = stub(getBuild, "getOs", () => {
return "linux";
});
const decompressStub = stub(DenoWrapper.zip, "decompress");
DenoWrapper.build.os = "linux";
try {
await new InstallAction().execute(
{ name: "unzip", postProcesses: ["unzip"] },
"https://example.com/dummy.zip",
);
assert(fileExists("data_files/unzip/dummy.zip"));
assertSpyCall(denoRunStub, 0, {
args: [{
cmd: ["unzip", "./data_files/unzip/dummy.zip", "-d", "./data_files/unzip"],
}],
assertSpyCall(decompressStub, 0, {
args: ["./data_files/unzip/dummy.zip", "./data_files/unzip"],
});
} finally {
osStub.restore();
denoCloseStub.restore();
denoRunStub.restore();
decompressStub.restore();
kyGetStub.restore();
}
});
Expand Down

0 comments on commit 2df3a0f

Please sign in to comment.