use mock services too

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2024-12-16 08:37:13 +01:00
parent ae2408b4ff
commit 4fd86b6afc
2 changed files with 9 additions and 30 deletions
@@ -14,13 +14,9 @@
* limitations under the License.
*/
import { rootLifecycleServiceFactory } from '@backstage/backend-defaults/rootLifecycle';
import { lifecycleServiceFactory } from '@backstage/backend-defaults/lifecycle';
import { loggerServiceFactory } from '@backstage/backend-defaults/logger';
import {
createServiceRef,
createServiceFactory,
coreServices,
createBackendPlugin,
createBackendModule,
createExtensionPoint,
@@ -29,26 +25,13 @@ import {
} from '@backstage/backend-plugin-api';
import { BackendInitializer } from './BackendInitializer';
import { instanceMetadataServiceRef } from '@backstage/backend-plugin-api/alpha';
class MockLogger {
debug() {}
info() {}
warn() {}
error() {}
child() {
return this;
}
}
import { mockServices } from '@backstage/backend-test-utils';
const baseFactories = [
lifecycleServiceFactory,
rootLifecycleServiceFactory,
createServiceFactory({
service: coreServices.rootLogger,
deps: {},
factory: () => new MockLogger(),
}),
loggerServiceFactory,
mockServices.rootLifecycle.factory(),
mockServices.lifecycle.factory(),
mockServices.rootLogger.factory(),
mockServices.logger.factory(),
];
function mkNoopFactory(ref: ServiceRef<{}, 'plugin'>) {
@@ -707,12 +690,8 @@ describe('BackendInitializer', () => {
const extA = createExtensionPoint<string>({ id: 'a' });
const extB = createExtensionPoint<string>({ id: 'b' });
const init = new BackendInitializer([
rootLifecycleServiceFactory,
createServiceFactory({
service: coreServices.rootLogger,
deps: {},
factory: () => new MockLogger(),
}),
mockServices.rootLifecycle.factory(),
mockServices.rootLogger.factory(),
]);
init.add(testPlugin);
init.add(
@@ -119,7 +119,7 @@ function createInstanceMetadataServiceFactory(
'toString',
{
enumerable: false,
configurable: false,
configurable: true,
value: () => `plugin{pluginId=${feature.pluginId}}`,
},
);
@@ -133,7 +133,7 @@ function createInstanceMetadataServiceFactory(
'toString',
{
enumerable: false,
configurable: false,
configurable: true,
value: () =>
`module{moduleId=${feature.moduleId},pluginId=${feature.pluginId}}`,
},