Add tests for validation and completion
This commit is contained in:
@@ -749,6 +749,57 @@ jobs:
|
|||||||
expect(result.map(x => x.label)).toEqual(["container", "services", "status"]);
|
expect(result.map(x => x.label)).toEqual(["container", "services", "status"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("job context is suggested within a job output", async () => {
|
||||||
|
const input = `
|
||||||
|
on: push
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
environment: \${{ | }}
|
||||||
|
steps:
|
||||||
|
- id: a
|
||||||
|
run: echo hi
|
||||||
|
`;
|
||||||
|
|
||||||
|
const result = await complete(...getPositionFromCursor(input), undefined, contextProviderConfig);
|
||||||
|
expect(result.map(x => x.label)).toEqual([
|
||||||
|
"env",
|
||||||
|
"github",
|
||||||
|
"inputs",
|
||||||
|
"job",
|
||||||
|
"needs",
|
||||||
|
"runner",
|
||||||
|
"secrets",
|
||||||
|
"steps",
|
||||||
|
"vars",
|
||||||
|
"contains",
|
||||||
|
"endsWith",
|
||||||
|
"format",
|
||||||
|
"fromJson",
|
||||||
|
"join",
|
||||||
|
"startsWith",
|
||||||
|
"toJson",
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("step context is suggested within a job output", async () => {
|
||||||
|
const input = `
|
||||||
|
on: push
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
environment: \${{ steps.| }}
|
||||||
|
steps:
|
||||||
|
- id: foo
|
||||||
|
run: echo hi
|
||||||
|
`;
|
||||||
|
|
||||||
|
const result = await complete(...getPositionFromCursor(input), undefined, contextProviderConfig);
|
||||||
|
expect(result.map(x => x.label)).toEqual(["foo"]);
|
||||||
|
});
|
||||||
|
|
||||||
it("container context is suggested within a job container", async () => {
|
it("container context is suggested within a job container", async () => {
|
||||||
const input = `
|
const input = `
|
||||||
on: push
|
on: push
|
||||||
|
|||||||
@@ -190,6 +190,39 @@ jobs:
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("reference of invalid step in job outputs", async () => {
|
||||||
|
const input = `
|
||||||
|
on: push
|
||||||
|
jobs:
|
||||||
|
a:
|
||||||
|
outputs:
|
||||||
|
environment: \${{ steps.foo }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- id: a
|
||||||
|
run: echo hello a
|
||||||
|
`;
|
||||||
|
|
||||||
|
const result = await validate(createDocument("wf.yaml", input));
|
||||||
|
|
||||||
|
expect(result).toEqual([
|
||||||
|
{
|
||||||
|
"message": "Context access might be invalid: foo",
|
||||||
|
"range": {
|
||||||
|
"end": {
|
||||||
|
"character": 41,
|
||||||
|
"line": 5,
|
||||||
|
},
|
||||||
|
"start": {
|
||||||
|
"character": 25,
|
||||||
|
"line": 5,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"severity": 2,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
it("invalid reference of generated step name", async () => {
|
it("invalid reference of generated step name", async () => {
|
||||||
const input = `
|
const input = `
|
||||||
on: push
|
on: push
|
||||||
|
|||||||
Reference in New Issue
Block a user