Skip to content

Commit

Permalink
fix: more tests, more stability
Browse files Browse the repository at this point in the history
  • Loading branch information
kristof-mattei committed Sep 12, 2023
1 parent 887f717 commit 32dccc8
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/tests/input.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,37 @@
import { get } from "../input";

describe("input", () => {
test("get", () => {
const OLD_ENV = process.env;

beforeEach(() => {
process.env = { ...OLD_ENV };
});

afterAll(() => {
process.env = OLD_ENV;
});

test("get 1, parses defaults", () => {
expect(get()).toStrictEqual({ args: [], toolchain: undefined, useCross: false });
});

test("get 2, can use cross", () => {
process.env["INPUT_USE-CROSS"] = "true";
expect(get()).toStrictEqual({ args: [], toolchain: undefined, useCross: true });
});

test("get 3, parses toolchain", () => {
process.env["INPUT_TOOLCHAIN"] = "nightly";
expect(get()).toStrictEqual({ args: [], toolchain: "nightly", useCross: false });
});

test("get 4, parses +toolchain to toolchain", () => {
process.env["INPUT_TOOLCHAIN"] = "+nightly";
expect(get()).toStrictEqual({ args: [], toolchain: "nightly", useCross: false });
});

test("get 5, parses arguments", () => {
process.env["INPUT_ARGS"] = "--all-features --all-targets";
expect(get()).toStrictEqual({ args: ["--all-features", "--all-targets"], toolchain: undefined, useCross: false });
});
});

0 comments on commit 32dccc8

Please sign in to comment.