From 32dccc8765daa0489934ee45e77604f5362a08cc Mon Sep 17 00:00:00 2001 From: Kristof Mattei <864376+Kristof-Mattei@users.noreply.github.com> Date: Tue, 12 Sep 2023 12:38:07 -0700 Subject: [PATCH] fix: more tests, more stability --- src/tests/input.test.ts | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/tests/input.test.ts b/src/tests/input.test.ts index 0a6f2cfa..7fc27195 100644 --- a/src/tests/input.test.ts +++ b/src/tests/input.test.ts @@ -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 }); + }); });