From 51fb0a1d80051355ad689b56c4695f4af26efb46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Wed, 6 Jul 2022 16:39:19 +0200 Subject: [PATCH] fixup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .../src/lib/transform/include.test.ts | 2 +- .../modules/core/PlaceholderProcessor.test.ts | 2 +- .../src/modules/util/parse.test.ts | 34 ++++++++++++------- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/packages/config-loader/src/lib/transform/include.test.ts b/packages/config-loader/src/lib/transform/include.test.ts index 91df723621..0913b31f66 100644 --- a/packages/config-loader/src/lib/transform/include.test.ts +++ b/packages/config-loader/src/lib/transform/include.test.ts @@ -155,7 +155,7 @@ describe('includeTransform', () => { await expect( includeTransform({ $include: 'invalid.yaml' }, root), ).rejects.toThrow( - 'failed to parse included file invalid.yaml, YAMLSyntaxError: Flow sequence contains an unexpected }', + /failed to parse included file invalid.yaml, YAMLParseError: Flow sequence in block collection must be sufficiently indented and end with a \] at line 1, column 7:\s+foo: \[\}/, ); }); diff --git a/plugins/catalog-backend/src/modules/core/PlaceholderProcessor.test.ts b/plugins/catalog-backend/src/modules/core/PlaceholderProcessor.test.ts index adff97336e..50cbdf9dd4 100644 --- a/plugins/catalog-backend/src/modules/core/PlaceholderProcessor.test.ts +++ b/plugins/catalog-backend/src/modules/core/PlaceholderProcessor.test.ts @@ -376,7 +376,7 @@ describe('yamlPlaceholderResolver', () => { it('rejects invalid yaml', async () => { read.mockResolvedValue(Buffer.from('a: 1\n----\n', 'utf-8')); await expect(yamlPlaceholderResolver(params)).rejects.toThrow( - 'Placeholder $a found an error in the data at ./file.yaml, YAMLSemanticError: Implicit map keys need to be followed by map values', + /Placeholder \$a found an error in the data at .\/file.yaml, YAMLParseError: Implicit map keys need to be followed by map values at line 2, column 1:\s+a: 1/, ); }); diff --git a/plugins/catalog-backend/src/modules/util/parse.test.ts b/plugins/catalog-backend/src/modules/util/parse.test.ts index e87de1c9a3..eda1723198 100644 --- a/plugins/catalog-backend/src/modules/util/parse.test.ts +++ b/plugins/catalog-backend/src/modules/util/parse.test.ts @@ -156,12 +156,16 @@ describe('parseEntityYaml', () => { ); // Parse errors are always per document - expect(results).toEqual([ - processingResult.generalError( - testLoc, - 'YAML error at my-loc-type:my-loc-target, YAMLSemanticError: Plain value cannot start with reserved character `', - ), - ]); + expect(results.length).toBe(1); + expect(results[0]).toEqual({ + type: 'error', + location: testLoc, + error: expect.objectContaining({ + message: expect.stringMatching( + /YAML error at my-loc-type:my-loc-target, YAMLParseError: Plain value cannot start with reserved character ` at line 1, column 1:/, + ), + }), + }); }); it('should emit parsing errors for individual documents', () => { @@ -185,7 +189,8 @@ describe('parseEntityYaml', () => { ), ); - expect(results).toEqual([ + expect(results.length).toBe(2); + expect(results[0]).toEqual( processingResult.entity(testLoc, { apiVersion: 'backstage.io/v1alpha1', kind: 'Component', @@ -196,11 +201,16 @@ describe('parseEntityYaml', () => { type: 'website', }, }), - processingResult.generalError( - testLoc, - 'YAML error at my-loc-type:my-loc-target, YAMLSemanticError: Nested mappings are not allowed in compact mappings', - ), - ]); + ); + expect(results[1]).toEqual({ + type: 'error', + location: testLoc, + error: expect.objectContaining({ + message: expect.stringMatching( + /YAML error at my-loc-type:my-loc-target, YAMLParseError: Nested mappings are not allowed in compact mappings at line 9, column 19:\s+apiVersion: backstage.io\/v1alpha1/, + ), + }), + }); }); it('must be an object at root', () => {