rs-cargo/__tests__/input.test.ts

34 lines
1 KiB
TypeScript
Raw Normal View History

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",
// 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", () => {
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
});
});