From f59722dcfa706c39bf941a25192ad5671dc8af77 Mon Sep 17 00:00:00 2001 From: Isabel Tomb Date: Fri, 13 Dec 2024 16:30:45 -0600 Subject: [PATCH] Add test Add a test to test the scenario that the previous commit fixes. If a repo has a malformed CODEOWNERS file that contains just a pattern and no names the match object will have an empty `owners` array, in which case resolveCodeOwner should return undefined. Signed-off-by: Isabel Tomb --- .../src/processors/codeowners/resolve.test.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/catalog-backend/src/processors/codeowners/resolve.test.ts b/plugins/catalog-backend/src/processors/codeowners/resolve.test.ts index f9cdf79530..722d27fdb9 100644 --- a/plugins/catalog-backend/src/processors/codeowners/resolve.test.ts +++ b/plugins/catalog-backend/src/processors/codeowners/resolve.test.ts @@ -46,6 +46,14 @@ describe('resolveCodeOwner', () => { ), ).toBe('team-foo'); }); + it('should return undefined if the codeowners file contains no names', () => { + expect( + resolveCodeOwner( + `*`, + 'https://github.com/acme/repo/tree/docs/catalog-info.yaml', + ), + ).toBe(undefined); + }); }); describe('normalizeCodeOwner', () => {