From 15b904f56c934ad7b44936f8f7d73f8d3a341903 Mon Sep 17 00:00:00 2001 From: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Tue, 20 Oct 2026 04:39:50 -0400 Subject: [PATCH] test(config): pin org-tier lgtm/sweep survival in mergeProwConfig, object values without color, values without exclusive, and the no-unknown-keys debug silence Three tests in __tests__/utils/config.test.ts, each killing a mutant of src/utils/config.ts that the whole 'vitest related' set left alive or that only labelCatalog.test.ts happened to catch: - mergeProwConfig: an organization lgtm.bind_to_commit / sweep.lookback must survive a repository prow.yaml with no such section, and must be overridden when the repository names one (lines 740, 741) - label values: { name } and { name, description } without a color parse, in a list and in a values: mapping that omits exclusive (lines 451, 469, 472) - parseProwConfig: core.debug is not called when every top level key is known (line 421) Fixes #534 Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- __tests__/utils/config.test.ts | 35 ++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/__tests__/utils/config.test.ts b/__tests__/utils/config.test.ts index 22114830..9ab632b9 100644 --- a/__tests__/utils/config.test.ts +++ b/__tests__/utils/config.test.ts @@ -142,6 +142,21 @@ describe('parseProwConfig', () => { }) }) + it('accepts an object value without a color, in a list and in a values mapping without exclusive', () => { + expect(parseProwConfig('x', 'kind:\n - { name: bug }\n - { name: docs, description: Documentation only }\n')).toEqual({ + labels: { + kind: { + values: ['bug', 'docs'], + definitions: [{ name: 'bug' }, { name: 'docs', description: 'Documentation only' }], + }, + }, + }) + + const section = parseProwConfig('x', 'kind:\n values:\n - { name: bug }\n').labels!.kind + expect(section).toEqual({ values: ['bug'], definitions: [{ name: 'bug' }] }) + expect(section.exclusive).toBeUndefined() + }) + it('rejects a color that is not six hex digits', () => { expect(() => parseProwConfig('x', 'kind:\n - { name: bug, color: "#d73a4a" }\n')).toThrow( `kind: invalid color '#d73a4a' for label 'bug', expected 6 hex digits`, @@ -417,6 +432,14 @@ describe('parseProwConfig', () => { expect(debug).toHaveBeenCalledWith('prow.yaml: ignoring unknown top level keys: plugins, owners') }) + it('does not log when every top level key is known', () => { + const debug = vi.spyOn(core, 'debug') + + parseProwConfig('prow.yaml', 'labels:\n kind: [bug]\ntide:\n merge_method: squash\n') + + expect(debug).not.toHaveBeenCalled() + }) + it.each([ ['an empty string', ''], ['a document marker only', '---\n'], @@ -488,6 +511,18 @@ describe('mergeProwConfig', () => { }) }) + it('keeps the organization lgtm and sweep sections when the repository names neither, and lets the repository override them', () => { + const org = parseProwConfig('org', 'lgtm:\n bind_to_commit: true\nsweep:\n lookback: 6h\n') + const repo = parseProwConfig('repo', 'labels:\n kind: [bug]\n') + + expect(mergeProwConfig(org, repo).lgtm).toEqual({ bind_to_commit: true }) + expect(mergeProwConfig(org, repo).sweep).toEqual({ lookback: '6h' }) + + const override = parseProwConfig('repo', 'lgtm:\n bind_to_commit: false\nsweep:\n lookback: 30m\n') + expect(mergeProwConfig(org, override).lgtm).toEqual({ bind_to_commit: false }) + expect(mergeProwConfig(org, override).sweep).toEqual({ lookback: '30m' }) + }) + it('merges authorization per key, repo over org, and unions users without case-insensitive duplicates', () => { const org = parseProwConfig('org', 'authorization:\n labels: trusted\n hold: trusted\n review: trusted\n users: [Alice, bob]\n') const repo = parseProwConfig('repo', 'authorization:\n hold: anyone\n close: members\n users: [alice, Carol]\n')