make sure values not provided by users resolve to undefined (#144)
This commit is contained in:
parent
815e458579
commit
730b76a669
@ -11,7 +11,7 @@ import * as assert from "assert";
|
|||||||
|
|
||||||
describe("util", () => {
|
describe("util", () => {
|
||||||
describe("uploadUrl", () => {
|
describe("uploadUrl", () => {
|
||||||
it("stripts template", () => {
|
it("strips template", () => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
uploadUrl(
|
uploadUrl(
|
||||||
"https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets{?name,label}"
|
"https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets{?name,label}"
|
||||||
@ -95,21 +95,33 @@ describe("util", () => {
|
|||||||
});
|
});
|
||||||
describe("parseConfig", () => {
|
describe("parseConfig", () => {
|
||||||
it("parses basic config", () => {
|
it("parses basic config", () => {
|
||||||
assert.deepStrictEqual(parseConfig({}), {
|
assert.deepStrictEqual(
|
||||||
github_ref: "",
|
parseConfig({
|
||||||
github_repository: "",
|
// note: inputs declared in actions.yml, even when declared not required,
|
||||||
github_token: "",
|
// are still provided by the actions runtime env as empty strings instead of
|
||||||
input_body: undefined,
|
// the normal absent env value one would expect. this breaks things
|
||||||
input_body_path: undefined,
|
// as an empty string !== undefined in terms of what we pass to the api
|
||||||
input_draft: undefined,
|
// so we cover that in a test case here to ensure undefined values are actually
|
||||||
input_prerelease: undefined,
|
// resolved as undefined and not empty strings
|
||||||
input_files: [],
|
INPUT_TARGET_COMMITISH: "",
|
||||||
input_name: undefined,
|
INPUT_DISCUSSION_CATEGORY_NAME: ""
|
||||||
input_tag_name: undefined,
|
}),
|
||||||
input_fail_on_unmatched_files: false,
|
{
|
||||||
input_target_commitish: undefined,
|
github_ref: "",
|
||||||
input_discussion_category_name: undefined
|
github_repository: "",
|
||||||
});
|
github_token: "",
|
||||||
|
input_body: undefined,
|
||||||
|
input_body_path: undefined,
|
||||||
|
input_draft: undefined,
|
||||||
|
input_prerelease: undefined,
|
||||||
|
input_files: [],
|
||||||
|
input_name: undefined,
|
||||||
|
input_tag_name: undefined,
|
||||||
|
input_fail_on_unmatched_files: false,
|
||||||
|
input_target_commitish: undefined,
|
||||||
|
input_discussion_category_name: undefined
|
||||||
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("parses basic config with commitish", () => {
|
it("parses basic config with commitish", () => {
|
||||||
|
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
@ -63,8 +63,9 @@ export const parseConfig = (env: Env): Config => {
|
|||||||
? env.INPUT_PRERELEASE == "true"
|
? env.INPUT_PRERELEASE == "true"
|
||||||
: undefined,
|
: undefined,
|
||||||
input_fail_on_unmatched_files: env.INPUT_FAIL_ON_UNMATCHED_FILES == "true",
|
input_fail_on_unmatched_files: env.INPUT_FAIL_ON_UNMATCHED_FILES == "true",
|
||||||
input_target_commitish: env.INPUT_TARGET_COMMITISH,
|
input_target_commitish: env.INPUT_TARGET_COMMITISH || undefined,
|
||||||
input_discussion_category_name: env.INPUT_DISCUSSION_CATEGORY_NAME
|
input_discussion_category_name:
|
||||||
|
env.INPUT_DISCUSSION_CATEGORY_NAME || undefined
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user