Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions __tests__/utils/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down Expand Up @@ -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'],
Expand Down Expand Up @@ -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')
Expand Down
Loading