backend-app-api: add support for adding module imports
Co-authored-by: Fredrik Adelöw <freben@gmail.com> Co-authored-by: Johan Haals <johan.haals@gmail.com> Co-authored-by: Camila Belo <camilaibs@gmail.com> Co-authored-by: Philipp Hugenroth <philipph@spotify.com> Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -18,27 +18,19 @@ import {
|
||||
coreServices,
|
||||
createServiceFactory,
|
||||
} from '@backstage/backend-plugin-api';
|
||||
import { mockServices } from '@backstage/backend-test-utils';
|
||||
import { createBackend } from './CreateBackend';
|
||||
|
||||
describe('createBackend', () => {
|
||||
it('should not throw when overriding a default service implementation', () => {
|
||||
it('should not throw when overriding a default service implementation', async () => {
|
||||
const backend = createBackend();
|
||||
|
||||
expect(() => {
|
||||
backend.add(
|
||||
createServiceFactory({
|
||||
service: coreServices.rootLifecycle,
|
||||
deps: {},
|
||||
factory: async () => ({
|
||||
addStartupHook: () => {},
|
||||
addShutdownHook: () => {},
|
||||
}),
|
||||
}),
|
||||
);
|
||||
}).not.toThrow();
|
||||
backend.add(mockServices.rootConfig.factory());
|
||||
|
||||
await expect(backend.start()).resolves.toBe(undefined);
|
||||
});
|
||||
|
||||
it('should throw on duplicate service implementations', () => {
|
||||
it('should throw on duplicate service implementations', async () => {
|
||||
const backend = createBackend();
|
||||
|
||||
backend.add(
|
||||
@@ -51,34 +43,34 @@ describe('createBackend', () => {
|
||||
}),
|
||||
}),
|
||||
);
|
||||
|
||||
expect(() => {
|
||||
backend.add(
|
||||
createServiceFactory({
|
||||
service: coreServices.rootLifecycle,
|
||||
deps: {},
|
||||
factory: async () => ({
|
||||
addStartupHook: () => {},
|
||||
addShutdownHook: () => {},
|
||||
}),
|
||||
backend.add(
|
||||
createServiceFactory({
|
||||
service: coreServices.rootLifecycle,
|
||||
deps: {},
|
||||
factory: async () => ({
|
||||
addStartupHook: () => {},
|
||||
addShutdownHook: () => {},
|
||||
}),
|
||||
);
|
||||
}).toThrow(
|
||||
}),
|
||||
);
|
||||
|
||||
await expect(backend.start()).rejects.toThrow(
|
||||
'Duplicate service implementations provided for core.rootLifecycle',
|
||||
);
|
||||
});
|
||||
|
||||
it('should throw when providing a plugin metadata service implementation', () => {
|
||||
it('should throw when providing a plugin metadata service implementation', async () => {
|
||||
const backend = createBackend();
|
||||
backend.add(
|
||||
createServiceFactory({
|
||||
service: coreServices.pluginMetadata,
|
||||
deps: {},
|
||||
factory: () => ({ getId: () => 'test' }),
|
||||
}),
|
||||
);
|
||||
|
||||
expect(() =>
|
||||
backend.add(
|
||||
createServiceFactory({
|
||||
service: coreServices.pluginMetadata,
|
||||
deps: {},
|
||||
factory: async () => ({ getId: () => 'test' }),
|
||||
}),
|
||||
),
|
||||
).toThrow('The core.pluginMetadata service cannot be overridden');
|
||||
await expect(backend.start()).rejects.toThrow(
|
||||
'The core.pluginMetadata service cannot be overridden',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user