mirror of
https://github.com/jdalrymple/gitbeaker.git
synced 2026-01-25 16:04:01 +00:00
Add ability to request merged_yaml from the Gitlab Lint API (#2185)
This commit is contained in:
parent
193348484f
commit
bfc5cbd643
@ -1,14 +1,15 @@
|
||||
import { BaseResource } from '@gitbeaker/requester-utils';
|
||||
import { RequestHelper, Sudo } from '../infrastructure';
|
||||
import { BaseRequestOptions, RequestHelper } from '../infrastructure';
|
||||
|
||||
export interface LintSchema extends Record<string, unknown> {
|
||||
status: string;
|
||||
errors?: string[];
|
||||
warnings?: string[];
|
||||
merged_yaml?: string;
|
||||
}
|
||||
|
||||
export class Lint<C extends boolean = false> extends BaseResource<C> {
|
||||
lint(content: string, options?: Sudo) {
|
||||
lint(content: string, options?: BaseRequestOptions) {
|
||||
return RequestHelper.post<LintSchema>()(this, 'ci/lint', { content, ...options });
|
||||
}
|
||||
}
|
||||
|
||||
41
packages/node/test/integration/resources/Lint.ts
Normal file
41
packages/node/test/integration/resources/Lint.ts
Normal file
@ -0,0 +1,41 @@
|
||||
import 'jest-extended';
|
||||
import { Lint } from '../../../src';
|
||||
|
||||
let lintAPI: InstanceType<typeof Lint>;
|
||||
|
||||
beforeEach(() => {
|
||||
lintAPI = new Lint({
|
||||
host: process.env.GITLAB_URL,
|
||||
token: process.env.GITLAB_PERSONAL_ACCESS_TOKEN,
|
||||
});
|
||||
});
|
||||
|
||||
describe('Lint.lint', () => {
|
||||
it('should return validate a lint without returning the merged_yaml', async () => {
|
||||
// Call the lint API, passing in a basic CI yaml, asking for the merged_yaml back.
|
||||
const input_ci_yaml = `
|
||||
test:
|
||||
stage: test
|
||||
script:
|
||||
- echo 1
|
||||
`;
|
||||
const result = await lintAPI.lint(input_ci_yaml);
|
||||
|
||||
expect(result).toBeInstanceOf(Object);
|
||||
expect(result).toContainKeys(['status']);
|
||||
});
|
||||
|
||||
it('should return the merged yaml in a lint request when requested', async () => {
|
||||
// Call the lint API, passing in a basic CI yaml, asking for the merged_yaml back.
|
||||
const input_ci_yaml = `
|
||||
test:
|
||||
stage: test
|
||||
script:
|
||||
- echo 1
|
||||
`;
|
||||
const result = await lintAPI.lint(input_ci_yaml, { includeMergedYaml: true });
|
||||
|
||||
expect(result).toBeInstanceOf(Object);
|
||||
expect(result).toContainKeys(['status', 'merged_yaml']);
|
||||
});
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user