Skip to content

Commit

Permalink
Improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
placintaalexandru committed Oct 28, 2023
1 parent 92ed4a1 commit 589c4fd
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions tests/installers/rustup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,42 @@ describe("Tests of rustup", () => {
);
});

test("Add targets", async () => {
(mockedIo.which as jest.Mock).mockReturnValue(
Promise.resolve("/somepath/rustup"),
);

const rustUpPath = await mockedIo.which("rustup");
const rustUp = await RustUp.getOrInstall();

const toolchainOptions = {
toolchain: "1.73.0",
profile: "minimal",
components: ["rustfmt", "clippy"],
targets: ["some target"],
default: false,
override: false,
force: false,
noSelfUpdate: false,
allowDowngrade: false,
};

await rustUp.addTargets(toolchainOptions);

expect(mockedExec.exec).toHaveBeenCalledTimes(1);
expect(mockedExec.exec).toHaveBeenCalledWith(
rustUpPath,
[
"target",
"add",
toolchainOptions.targets[0],
"--toolchain",
toolchainOptions.toolchain,
],
undefined,
);
});

test("Install toolchain: no self update, downgrade & force", async () => {
(mockedIo.which as jest.Mock).mockReturnValue(
Promise.resolve("/somepath/rustup"),
Expand Down Expand Up @@ -203,4 +239,23 @@ describe("Tests of rustup", () => {
undefined,
);
});

test("Set profile", async () => {
(mockedIo.which as jest.Mock).mockReturnValue(
Promise.resolve("/somepath/rustup"),
);

const rustUpPath = await mockedIo.which("rustup");
const rustUp = await RustUp.getOrInstall();
const profile = "default";

await rustUp.setProfile(profile);

expect(mockedExec.exec).toHaveBeenCalledTimes(1);
expect(mockedExec.exec).toHaveBeenCalledWith(
rustUpPath,
["set", "profile", profile],
undefined,
);
});
});

0 comments on commit 589c4fd

Please sign in to comment.