Merge pull request #5150 from jmgrimes/dependsOn-dependencyOf-relationships

Implemented dependsOn/dependencyOf support in catalog model.
This commit is contained in:
Fredrik Adelöw
2021-04-12 13:40:00 +02:00
committed by GitHub
11 changed files with 251 additions and 6 deletions
@@ -36,6 +36,7 @@ describe('ComponentV1alpha1Validator', () => {
subcomponentOf: 'monolith',
providesApis: ['api-0'],
consumesApis: ['api-0'],
dependsOn: ['resource:resource-0', 'component:component-0'],
system: 'system',
},
};
@@ -160,6 +161,26 @@ describe('ComponentV1alpha1Validator', () => {
await expect(validator.check(entity)).resolves.toBe(true);
});
it('accepts missing dependsOn', async () => {
delete (entity as any).spec.dependsOn;
await expect(validator.check(entity)).resolves.toBe(true);
});
it('rejects empty dependsOn', async () => {
(entity as any).spec.dependsOn = [''];
await expect(validator.check(entity)).rejects.toThrow(/dependsOn/);
});
it('rejects undefined dependsOn', async () => {
(entity as any).spec.dependsOn = [undefined];
await expect(validator.check(entity)).rejects.toThrow(/dependsOn/);
});
it('accepts no dependsOn', async () => {
(entity as any).spec.dependsOn = [];
await expect(validator.check(entity)).resolves.toBe(true);
});
it('accepts missing system', async () => {
delete (entity as any).spec.system;
await expect(validator.check(entity)).resolves.toBe(true);
@@ -34,6 +34,7 @@ export interface ComponentEntityV1alpha1 extends Entity {
subcomponentOf?: string;
providesApis?: string[];
consumesApis?: string[];
dependsOn?: string[];
system?: string;
};
}
@@ -32,6 +32,7 @@ describe('ResourceV1alpha1Validator', () => {
spec: {
type: 'database',
owner: 'me',
dependsOn: ['component:component-0', 'resource:resource-0'],
system: 'system',
},
};
@@ -86,6 +87,26 @@ describe('ResourceV1alpha1Validator', () => {
await expect(validator.check(entity)).rejects.toThrow(/owner/);
});
it('accepts missing dependsOn', async () => {
delete (entity as any).spec.dependsOn;
await expect(validator.check(entity)).resolves.toBe(true);
});
it('rejects empty dependsOn', async () => {
(entity as any).spec.dependsOn = [''];
await expect(validator.check(entity)).rejects.toThrow(/dependsOn/);
});
it('rejects undefined dependsOn', async () => {
(entity as any).spec.dependsOn = [undefined];
await expect(validator.check(entity)).rejects.toThrow(/dependsOn/);
});
it('accepts no dependsOn', async () => {
(entity as any).spec.dependsOn = [];
await expect(validator.check(entity)).resolves.toBe(true);
});
it('accepts missing system', async () => {
delete (entity as any).spec.system;
await expect(validator.check(entity)).resolves.toBe(true);
@@ -30,6 +30,7 @@ export interface ResourceEntityV1alpha1 extends Entity {
spec: {
type: string;
owner: string;
dependsOn?: string[];
system?: string;
};
}
@@ -84,6 +84,14 @@
"type": "string",
"minLength": 1
}
},
"dependsOn": {
"type": "array",
"description": "An array of references to other entities that the component depends on to function.",
"items": {
"type": "string",
"minLength": 1
}
}
}
}
@@ -47,6 +47,14 @@
"examples": ["artist-relations-team", "user:john.johnson"],
"minLength": 1
},
"dependsOn": {
"type": "array",
"description": "An array of references to other entities that the resource depends on to function.",
"items": {
"type": "string",
"minLength": 1
}
},
"system": {
"type": "string",
"description": "An entity reference to the system that the resource belongs to.",