Expression validation

This commit is contained in:
Christopher Schleiden
2022-11-21 17:55:47 -08:00
parent eb9daaccd2
commit bf7e440692
9 changed files with 248 additions and 84 deletions
@@ -0,0 +1,57 @@
import {DiagnosticSeverity} from "vscode-languageserver-types";
import {createDocument} from "./test-utils/document";
import {validate} from "./validate";
describe("expression validation", () => {
it("access invalid context field", async () => {
const result = await validate(
createDocument(
"wf.yaml",
"on: push\nrun-name: name-${{ github.does-not-exist }}\njobs:\n build:\n runs-on: ubuntu-latest\n steps:\n - run: echo"
)
);
expect(result).toEqual([
{
message: "Context might be invalid: does-not-exist",
range: {
end: {
character: 43,
line: 1
},
start: {
character: 10,
line: 1
}
},
severity: DiagnosticSeverity.Warning
}
]);
});
it("access invalid nested context field", async () => {
const result = await validate(
createDocument(
"wf.yaml",
"on: push\nrun-name: name-${{ github.does-not-exist.again }}\njobs:\n build:\n runs-on: ubuntu-latest\n steps:\n - run: echo"
)
);
expect(result).toEqual([
{
message: "Context might be invalid: does-not-exist",
range: {
end: {
character: 49,
line: 1
},
start: {
character: 10,
line: 1
}
},
severity: DiagnosticSeverity.Warning
}
]);
});
});