backend-test-utils: remove mock service refs

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2023-02-06 17:34:26 +01:00
parent 2c68a05fd3
commit f1adb2e36b
3 changed files with 12 additions and 44 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/backend-test-utils': patch
---
Removed the `ref` from all `mockServices`.
-27
View File
@@ -20,7 +20,6 @@ import { LifecycleService } from '@backstage/backend-plugin-api';
import { LoggerService } from '@backstage/backend-plugin-api';
import { PermissionsService } from '@backstage/backend-plugin-api';
import { RootLifecycleService } from '@backstage/backend-plugin-api';
import { RootLoggerService } from '@backstage/backend-plugin-api';
import { SchedulerService } from '@backstage/backend-plugin-api';
import { ServiceFactory } from '@backstage/backend-plugin-api';
import { ServiceRef } from '@backstage/backend-plugin-api';
@@ -34,8 +33,6 @@ export function isDockerDisabledForTests(): boolean;
export namespace mockServices {
// (undocumented)
export namespace cache {
const // (undocumented)
ref: ServiceRef<CacheService, 'plugin'>;
const // (undocumented)
factory: () => ServiceFactory<CacheService>;
}
@@ -47,22 +44,16 @@ export namespace mockServices {
export type Options = {
data?: JsonObject;
};
const // (undocumented)
ref: ServiceRef<ConfigService, 'root'>;
const // (undocumented)
factory: (options?: Options | undefined) => ServiceFactory<ConfigService>;
}
// (undocumented)
export namespace database {
const // (undocumented)
ref: ServiceRef<DatabaseService, 'plugin'>;
const // (undocumented)
factory: () => ServiceFactory<DatabaseService>;
}
// (undocumented)
export namespace httpRouter {
const // (undocumented)
ref: ServiceRef<HttpRouterService, 'plugin'>;
const // (undocumented)
factory: (
options?: HttpRouterFactoryOptions | undefined,
@@ -72,36 +63,26 @@ export namespace mockServices {
export function identity(): IdentityService;
// (undocumented)
export namespace identity {
const // (undocumented)
ref: ServiceRef<IdentityService, 'plugin'>;
const // (undocumented)
factory: () => ServiceFactory<IdentityService>;
}
// (undocumented)
export namespace lifecycle {
const // (undocumented)
ref: ServiceRef<LifecycleService, 'plugin'>;
const // (undocumented)
factory: () => ServiceFactory<LifecycleService>;
}
// (undocumented)
export namespace logger {
const // (undocumented)
ref: ServiceRef<LoggerService, 'plugin'>;
const // (undocumented)
factory: () => ServiceFactory<LoggerService>;
}
// (undocumented)
export namespace permissions {
const // (undocumented)
ref: ServiceRef<PermissionsService, 'plugin'>;
const // (undocumented)
factory: () => ServiceFactory<PermissionsService>;
}
// (undocumented)
export namespace rootLifecycle {
const // (undocumented)
ref: ServiceRef<RootLifecycleService, 'root'>;
const // (undocumented)
factory: () => ServiceFactory<RootLifecycleService>;
}
@@ -120,15 +101,11 @@ export namespace mockServices {
debug: boolean;
};
};
const // (undocumented)
ref: ServiceRef<RootLoggerService, 'root'>;
const // (undocumented)
factory: (options?: Options | undefined) => ServiceFactory<LoggerService>;
}
// (undocumented)
export namespace scheduler {
const // (undocumented)
ref: ServiceRef<SchedulerService, 'plugin'>;
const // (undocumented)
factory: () => ServiceFactory<SchedulerService>;
}
@@ -136,15 +113,11 @@ export namespace mockServices {
export function tokenManager(): TokenManagerService;
// (undocumented)
export namespace tokenManager {
const // (undocumented)
ref: ServiceRef<TokenManagerService, 'plugin'>;
const // (undocumented)
factory: () => ServiceFactory<TokenManagerService>;
}
// (undocumented)
export namespace urlReader {
const // (undocumented)
ref: ServiceRef<UrlReaderService, 'plugin'>;
const // (undocumented)
factory: () => ServiceFactory<UrlReaderService>;
}
@@ -62,8 +62,7 @@ export namespace mockServices {
export namespace config {
export type Options = { data?: JsonObject };
export const ref = coreServices.config;
export const factory = simpleFactory(ref, config);
export const factory = simpleFactory(coreServices.config, config);
}
export function rootLogger(options?: rootLogger.Options): LoggerService {
@@ -76,8 +75,7 @@ export namespace mockServices {
| { error: boolean; warn: boolean; info: boolean; debug: boolean };
};
export const ref = coreServices.rootLogger;
export const factory = simpleFactory(ref, rootLogger);
export const factory = simpleFactory(coreServices.rootLogger, rootLogger);
}
export function tokenManager(): TokenManagerService {
@@ -93,55 +91,47 @@ export namespace mockServices {
};
}
export namespace tokenManager {
export const ref = coreServices.tokenManager;
export const factory = simpleFactory(ref, tokenManager);
export const factory = simpleFactory(
coreServices.tokenManager,
tokenManager,
);
}
export function identity(): IdentityService {
return new MockIdentityService();
}
export namespace identity {
export const ref = coreServices.identity;
export const factory = simpleFactory(ref, identity);
export const factory = simpleFactory(coreServices.identity, identity);
}
// TODO(Rugvip): Not all core services have implementations available here yet.
// some may need a bit more refactoring for it to be simpler to
// re-implement functioning mock versions here.
export namespace cache {
export const ref = coreServices.cache;
export const factory = cacheFactory;
}
export namespace database {
export const ref = coreServices.database;
export const factory = databaseFactory;
}
export namespace httpRouter {
export const ref = coreServices.httpRouter;
export const factory = httpRouterFactory;
}
export namespace lifecycle {
export const ref = coreServices.lifecycle;
export const factory = lifecycleFactory;
}
export namespace logger {
export const ref = coreServices.logger;
export const factory = loggerFactory;
}
export namespace permissions {
export const ref = coreServices.permissions;
export const factory = permissionsFactory;
}
export namespace rootLifecycle {
export const ref = coreServices.rootLifecycle;
export const factory = rootLifecycleFactory;
}
export namespace scheduler {
export const ref = coreServices.scheduler;
export const factory = schedulerFactory;
}
export namespace urlReader {
export const ref = coreServices.urlReader;
export const factory = urlReaderFactory;
}
}