-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add accept cfg preflight checks signaling codeagent deprec
- Loading branch information
Showing
3 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Config } from '../../types/config'; | ||
import { CheckOptions, CheckResult } from '../types'; | ||
|
||
export const validateAcceptFlagsConfig = ( | ||
checkOptions: CheckOptions, | ||
config: Config, | ||
): CheckResult => { | ||
const acceptFlagKeys = Object.keys(config).filter((x) => | ||
x.startsWith('ACCEPT_'), | ||
); | ||
if ( | ||
config.ACCEPT && | ||
config.ACCEPT != 'accept.json' && | ||
acceptFlagKeys.length > 0 | ||
) { | ||
return { | ||
id: checkOptions.id, | ||
name: checkOptions.name, | ||
status: 'error', | ||
output: `ACCEPT_ flags are not compatible with custom accept.json files. Please refrain from using custom accept json (Code Agent is deprecated, see documentation).`, | ||
} satisfies CheckResult; | ||
} | ||
|
||
return { | ||
id: checkOptions.id, | ||
name: checkOptions.name, | ||
status: 'passing', | ||
output: 'ACCEPT flags configuration OK.', | ||
} satisfies CheckResult; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
test/unit/client/checks/config/acceptFlagsConfigCheck.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { validateAcceptFlagsConfig } from '../../../../../lib/client/checks/config/customAcceptFile'; | ||
import { aConfig } from '../../../../helpers/test-factories'; | ||
|
||
describe('client/checks/config', () => { | ||
describe('validateAcceptFlagsConfig()', () => { | ||
it('should return error check result if incompatible ACCEPT flags', async () => { | ||
const id = `check_${Date.now()}`; | ||
const config = aConfig({ | ||
ACCEPT_CODE: true, | ||
ACCEPT: '/path/to/custom/accept/file', | ||
}); | ||
|
||
const checkResult = validateAcceptFlagsConfig( | ||
{ id: id, name: id }, | ||
config, | ||
); | ||
expect(checkResult.status).toEqual('error'); | ||
expect(checkResult.output).toContain( | ||
'ACCEPT_ flags are not compatible with custom accept.json files. Please refrain from using custom accept json (Code Agent is deprecated, see documentation).', | ||
); | ||
}); | ||
|
||
it('should return error check result if incompatible ACCEPT numerous flags', async () => { | ||
const id = `check_${Date.now()}`; | ||
const config = aConfig({ | ||
ACCEPT_GIT: true, | ||
ACCEPT_IAC: true, | ||
ACCEPT_APPRISK: true, | ||
ACCEPT: '/path/to/custom/accept/file', | ||
}); | ||
|
||
const checkResult = validateAcceptFlagsConfig( | ||
{ id: id, name: id }, | ||
config, | ||
); | ||
expect(checkResult.status).toEqual('error'); | ||
expect(checkResult.output).toContain( | ||
'ACCEPT_ flags are not compatible with custom accept.json files. Please refrain from using custom accept json (Code Agent is deprecated, see documentation).', | ||
); | ||
}); | ||
|
||
it('should return passing check result if only ACCEPT custom file configured', async () => { | ||
const id = `check_${Date.now()}`; | ||
const config = aConfig({ | ||
ACCEPT: '/path/to/custom/accept/file', | ||
}); | ||
|
||
const checkResult = validateAcceptFlagsConfig( | ||
{ id: id, name: id }, | ||
config, | ||
); | ||
expect(checkResult.status).toEqual('passing'); | ||
expect(checkResult.output).toContain('ACCEPT flags configuration OK.'); | ||
}); | ||
|
||
it('should return passing check result if only ACCEPT_ flags configured', async () => { | ||
const id = `check_${Date.now()}`; | ||
const config = aConfig({ | ||
ACCEPT_CODE: true, | ||
}); | ||
|
||
const checkResult = validateAcceptFlagsConfig( | ||
{ id: id, name: id }, | ||
config, | ||
); | ||
expect(checkResult.status).toEqual('passing'); | ||
expect(checkResult.output).toContain('ACCEPT flags configuration OK.'); | ||
}); | ||
}); | ||
}); |