From 23d1ccc8b51602ea39ffcebb5d35ff011bf4b402 Mon Sep 17 00:00:00 2001 From: Theo Truong Date: Mon, 20 May 2024 19:43:39 -0600 Subject: [PATCH] # validator Signed-off-by: Theo Truong --- package.json | 3 ++- tests/index_lifecycle.yaml | 2 +- tools/src/tester/ResultsDisplayer.ts | 5 +++-- tools/src/tester/test.ts | 9 +++++++++ 4 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 tools/src/tester/test.ts diff --git a/package.json b/package.json index 526e9f8ed..22227e1a2 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "lint:spec": "ts-node tools/src/linter/lint.ts", "lint": "eslint .", "lint--fix": "eslint . --fix", - "test": "jest" + "test": "jest", + "test:spec": "ts-node tools/src/tester/test.ts" }, "dependencies": { "@apidevtools/swagger-parser": "^10.1.0", diff --git a/tests/index_lifecycle.yaml b/tests/index_lifecycle.yaml index 05ec1891c..7ea42963a 100644 --- a/tests/index_lifecycle.yaml +++ b/tests/index_lifecycle.yaml @@ -5,7 +5,7 @@ prologues: [] epilogues: - path: /books,movies,games method: DELETE - ignore_errors: true + ignore_errors: false chapters: - synopsis: Create an index named `books` with mappings and settings. path: /{index} diff --git a/tools/src/tester/ResultsDisplayer.ts b/tools/src/tester/ResultsDisplayer.ts index 0699b7aa6..fc5621028 100644 --- a/tools/src/tester/ResultsDisplayer.ts +++ b/tools/src/tester/ResultsDisplayer.ts @@ -27,8 +27,8 @@ export default class ResultsDisplayer { display (): void { this.#display_story() this.#display_prologues() - this.#display_epilogues() this.#display_chapters() + this.#display_epilogues() } #display_story (): void { @@ -45,8 +45,9 @@ export default class ResultsDisplayer { if (evaluations.some(e => e.result === Result.ERROR)) result = Result.ERROR else if (evaluations.some(e => e.result === Result.FAILED)) result = Result.FAILED else if (evaluations.every(e => e.result === Result.SKIPPED)) result = Result.SKIPPED - this.#display_evaluation({ result }, 'CHAPTERS', 3) + this.#display_evaluation({ result }, 'CHAPTERS', 3) + if (result === Result.PASSED) return for (const evaluation of evaluations) { this.#display_evaluation(evaluation, i(evaluation.synopsis), 6) } diff --git a/tools/src/tester/test.ts b/tools/src/tester/test.ts new file mode 100644 index 000000000..d821793d9 --- /dev/null +++ b/tools/src/tester/test.ts @@ -0,0 +1,9 @@ +import OpenApiMerger from '../merger/OpenApiMerger' +import { LogLevel } from '../Logger' +import TestsRunner from './TestsRunner' + +const spec = (new OpenApiMerger('./spec', LogLevel.error)).merge() +const runner = new TestsRunner(spec, './tests') +void runner.run().then(() => { + console.log('Tests run successfully.') +})