From 86dd16bd1248b92a263f54cfd7d8492bfa581fd1 Mon Sep 17 00:00:00 2001 From: Christopher Schleiden Date: Fri, 9 Dec 2022 08:38:09 -0800 Subject: [PATCH] Add some more validation tests --- .../src/validate.expressions.test.ts | 122 ++++++++++++++++++ 1 file changed, 122 insertions(+) diff --git a/actions-languageservice/src/validate.expressions.test.ts b/actions-languageservice/src/validate.expressions.test.ts index 0039471..b914ec9 100644 --- a/actions-languageservice/src/validate.expressions.test.ts +++ b/actions-languageservice/src/validate.expressions.test.ts @@ -306,6 +306,128 @@ jobs: }); }); + describe("multi-line strings", () => { + it("indented |", async () => { + const input = `on: push +jobs: + build: + runs-on: ubuntu-latest + steps: + - run: | + first line + test \${{ github.does-not-exist }} + test2`; + const result = await validate(createDocument("wf.yaml", input)); + + expect(result).toEqual([ + { + message: "Context access might be invalid: does-not-exist", + range: { + end: { + character: 43, + line: 7 + }, + start: { + character: 15, + line: 7 + } + }, + severity: DiagnosticSeverity.Warning + } + ]); + }); + + it("indented |+", async () => { + const input = `on: push +jobs: + build: + runs-on: ubuntu-latest + steps: + - run: |+ + first line + test \${{ github.does-not-exist }} + test2`; + const result = await validate(createDocument("wf.yaml", input)); + + expect(result).toEqual([ + { + message: "Context access might be invalid: does-not-exist", + range: { + end: { + character: 43, + line: 7 + }, + start: { + character: 15, + line: 7 + } + }, + severity: DiagnosticSeverity.Warning + } + ]); + }); + + it("indented >", async () => { + const input = `on: push +jobs: + build: + runs-on: ubuntu-latest + steps: + - run: > + first line + test \${{ github.does-not-exist }} + test2`; + const result = await validate(createDocument("wf.yaml", input)); + + expect(result).toEqual([ + { + message: "Context access might be invalid: does-not-exist", + range: { + end: { + character: 43, + line: 7 + }, + start: { + character: 15, + line: 7 + } + }, + severity: DiagnosticSeverity.Warning + } + ]); + }); + + it("indented >+", async () => { + const input = `on: push +jobs: + build: + runs-on: ubuntu-latest + steps: + - run: >+ + first line + test \${{ github.does-not-exist }} + test2`; + const result = await validate(createDocument("wf.yaml", input)); + + expect(result).toEqual([ + { + message: "Context access might be invalid: does-not-exist", + range: { + end: { + character: 43, + line: 7 + }, + start: { + character: 15, + line: 7 + } + }, + severity: DiagnosticSeverity.Warning + } + ]); + }); + }); + describe("matrix context", () => { it("reference within a matrix job", async () => { const input = `