Merge pull request #35 from github/joshmgross/validate-inputs-defined

Ensure `inputs` is defined
This commit is contained in:
Josh Gross
2022-12-06 11:08:57 -05:00
committed by GitHub
2 changed files with 56 additions and 31 deletions
@@ -241,6 +241,28 @@ jobs:
expect(result.map(x => x.label)).toEqual(["another-name", "name"]); expect(result.map(x => x.label)).toEqual(["another-name", "name"]);
}); });
it("no inputs", async () => {
const input = `
on:
workflow_dispatch:
jobs:
a:
outputs:
build_id: my-build-id
runs-on: ubuntu-latest
steps:
- run: echo hello a
b:
needs: [a]
runs-on: ubuntu-latest
steps:
- run: echo "hello \${{ inputs.|
`;
const result = await complete(...getPositionFromCursor(input), undefined, contextProviderConfig);
expect(result).toEqual([]);
});
describe("steps context", () => { describe("steps context", () => {
it("includes defined step IDs", async () => { it("includes defined step IDs", async () => {
const input = ` const input = `
@@ -13,6 +13,9 @@ export function getInputsContext(workflowContext: WorkflowContext): data.Diction
} }
const inputs = event.inputs; const inputs = event.inputs;
if (!inputs) {
return d;
}
for (const inputName of Object.keys(inputs)) { for (const inputName of Object.keys(inputs)) {
const input = inputs[inputName]; const input = inputs[inputName];
switch (input.type) { switch (input.type) {