2020-03-25 07:40:28 +02:00
|
|
|
import * as input from "../src/input";
|
2019-09-12 23:48:44 +03:00
|
|
|
|
|
|
|
const testEnvVars = {
|
2020-03-25 07:40:28 +02:00
|
|
|
INPUT_COMMAND: "build",
|
2019-09-13 22:45:36 +03:00
|
|
|
// There are few unnecessary spaces here to check that args parser works properly
|
2020-03-25 07:40:28 +02:00
|
|
|
INPUT_ARGS:
|
|
|
|
" --release --target x86_64-unknown-linux-gnu --no-default-features --features unstable ",
|
|
|
|
"INPUT_USE-CROSS": "true",
|
|
|
|
INPUT_TOOLCHAIN: "+nightly",
|
|
|
|
};
|
2019-09-12 23:48:44 +03:00
|
|
|
|
2020-03-25 07:40:28 +02:00
|
|
|
describe("actions-rs/cargo/input", () => {
|
2019-09-12 23:48:44 +03:00
|
|
|
beforeEach(() => {
|
2020-03-25 07:40:28 +02:00
|
|
|
for (const key in testEnvVars)
|
|
|
|
process.env[key] = testEnvVars[key as keyof typeof testEnvVars];
|
|
|
|
});
|
2019-09-12 23:48:44 +03:00
|
|
|
|
2020-03-25 07:40:28 +02:00
|
|
|
it("Parses action input into cargo input", () => {
|
2019-09-25 10:08:33 +03:00
|
|
|
const result = input.get();
|
2019-09-12 23:48:44 +03:00
|
|
|
|
2020-03-25 07:40:28 +02:00
|
|
|
expect(result.command).toBe("build");
|
2019-09-12 23:48:44 +03:00
|
|
|
expect(result.args).toStrictEqual([
|
2020-03-25 07:40:28 +02:00
|
|
|
"--release",
|
|
|
|
"--target",
|
|
|
|
"x86_64-unknown-linux-gnu",
|
|
|
|
"--no-default-features",
|
|
|
|
"--features",
|
|
|
|
"unstable",
|
2019-09-12 23:48:44 +03:00
|
|
|
]);
|
|
|
|
expect(result.useCross).toBe(true);
|
2020-03-25 07:40:28 +02:00
|
|
|
expect(result.toolchain).toBe("nightly");
|
2019-09-12 23:48:44 +03:00
|
|
|
});
|
|
|
|
});
|