Add subcomponentOf field to Component spec
This commit is contained in:
@@ -33,6 +33,7 @@ describe('ComponentV1alpha1Validator', () => {
|
||||
type: 'service',
|
||||
lifecycle: 'production',
|
||||
owner: 'me',
|
||||
subcomponentOf: 'monolith',
|
||||
providesApis: ['api-0'],
|
||||
consumesApis: ['api-0'],
|
||||
},
|
||||
@@ -103,6 +104,21 @@ describe('ComponentV1alpha1Validator', () => {
|
||||
await expect(validator.check(entity)).rejects.toThrow(/owner/);
|
||||
});
|
||||
|
||||
it('accepts missing subcomponentOf', async () => {
|
||||
delete (entity as any).spec.subcomponentOf;
|
||||
await expect(validator.check(entity)).resolves.toBe(true);
|
||||
});
|
||||
|
||||
it('rejects wrong subcomponentOf', async () => {
|
||||
(entity as any).spec.subcomponentOf = 7;
|
||||
await expect(validator.check(entity)).rejects.toThrow(/subcomponentOf/);
|
||||
});
|
||||
|
||||
it('rejects empty subcomponentOf', async () => {
|
||||
(entity as any).spec.subcomponentOf = '';
|
||||
await expect(validator.check(entity)).rejects.toThrow(/subcomponentOf/);
|
||||
});
|
||||
|
||||
it('accepts missing providesApis', async () => {
|
||||
delete (entity as any).spec.providesApis;
|
||||
await expect(validator.check(entity)).resolves.toBe(true);
|
||||
|
||||
@@ -29,6 +29,7 @@ const schema = yup.object<Partial<ComponentEntityV1alpha1>>({
|
||||
type: yup.string().required().min(1),
|
||||
lifecycle: yup.string().required().min(1),
|
||||
owner: yup.string().required().min(1),
|
||||
subcomponentOf: yup.string().notRequired().min(1),
|
||||
providesApis: yup.array(yup.string().required()).notRequired(),
|
||||
consumesApis: yup.array(yup.string().required()).notRequired(),
|
||||
})
|
||||
@@ -42,6 +43,7 @@ export interface ComponentEntityV1alpha1 extends Entity {
|
||||
type: string;
|
||||
lifecycle: string;
|
||||
owner: string;
|
||||
subcomponentOf?: string;
|
||||
providesApis?: string[];
|
||||
consumesApis?: string[];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user