@backstage/backend-test-utils 0.4.5-next.1 → 0.4.5-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/dist/index.cjs.js +143 -105
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +25 -25
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -350,7 +350,7 @@ interface ServiceFactoryTesterOptions {
|
|
|
350
350
|
*
|
|
351
351
|
* @public
|
|
352
352
|
*/
|
|
353
|
-
declare class ServiceFactoryTester<TService, TScope extends 'root' | 'plugin'> {
|
|
353
|
+
declare class ServiceFactoryTester<TService, TScope extends 'root' | 'plugin', TInstances extends 'singleton' | 'multiton' = 'singleton'> {
|
|
354
354
|
#private;
|
|
355
355
|
/**
|
|
356
356
|
* Creates a new {@link ServiceFactoryTester} used to test the provided subject.
|
|
@@ -359,14 +359,14 @@ declare class ServiceFactoryTester<TService, TScope extends 'root' | 'plugin'> {
|
|
|
359
359
|
* @param options - Additional options
|
|
360
360
|
* @returns A new tester instance for the provided subject.
|
|
361
361
|
*/
|
|
362
|
-
static from<TService, TScope extends 'root' | 'plugin'>(subject: ServiceFactory<TService, TScope>, options?: ServiceFactoryTesterOptions): ServiceFactoryTester<TService, TScope>;
|
|
362
|
+
static from<TService, TScope extends 'root' | 'plugin', TInstances extends 'singleton' | 'multiton' = 'singleton'>(subject: ServiceFactory<TService, TScope, TInstances>, options?: ServiceFactoryTesterOptions): ServiceFactoryTester<TService, TScope, TInstances>;
|
|
363
363
|
private constructor();
|
|
364
364
|
/**
|
|
365
365
|
* Returns the service instance for the subject.
|
|
366
366
|
*
|
|
367
367
|
* @deprecated Use `getSubject` instead.
|
|
368
368
|
*/
|
|
369
|
-
get(...args: 'root' extends TScope ? [] : [pluginId?: string]): Promise<TService>;
|
|
369
|
+
get(...args: 'root' extends TScope ? [] : [pluginId?: string]): Promise<TInstances extends 'multiton' ? TService[] : TService>;
|
|
370
370
|
/**
|
|
371
371
|
* Returns the service instance for the subject.
|
|
372
372
|
*
|
|
@@ -377,7 +377,7 @@ declare class ServiceFactoryTester<TService, TScope extends 'root' | 'plugin'> {
|
|
|
377
377
|
*
|
|
378
378
|
* By default the plugin ID 'test' is used.
|
|
379
379
|
*/
|
|
380
|
-
getSubject(...args: 'root' extends TScope ? [] : [pluginId?: string]): Promise<TService>;
|
|
380
|
+
getSubject(...args: 'root' extends TScope ? [] : [pluginId?: string]): Promise<TInstances extends 'multiton' ? TService[] : TService>;
|
|
381
381
|
/**
|
|
382
382
|
* Return the service instance for any of the provided dependencies or built-in services.
|
|
383
383
|
*
|
|
@@ -385,7 +385,7 @@ declare class ServiceFactoryTester<TService, TScope extends 'root' | 'plugin'> {
|
|
|
385
385
|
*
|
|
386
386
|
* A plugin ID can optionally be provided for plugin scoped services, otherwise the plugin ID 'test' is used.
|
|
387
387
|
*/
|
|
388
|
-
getService<TGetService, TGetScope extends 'root' | 'plugin'>(service: ServiceRef<TGetService, TGetScope>, ...args: 'root' extends TGetScope ? [] : [pluginId?: string]): Promise<TGetService>;
|
|
388
|
+
getService<TGetService, TGetScope extends 'root' | 'plugin', TGetInstances extends 'singleton' | 'multiton' = 'singleton'>(service: ServiceRef<TGetService, TGetScope, TGetInstances>, ...args: 'root' extends TGetScope ? [] : [pluginId?: string]): Promise<TGetInstances extends 'multiton' ? TGetService[] : TGetService>;
|
|
389
389
|
}
|
|
390
390
|
|
|
391
391
|
/** @public */
|
|
@@ -430,24 +430,24 @@ declare namespace mockServices {
|
|
|
430
430
|
type Options = {
|
|
431
431
|
data?: JsonObject;
|
|
432
432
|
};
|
|
433
|
-
const factory: ServiceFactory<RootConfigService, "root"> & ((options?: Options | undefined) => ServiceFactory<RootConfigService, "root">);
|
|
433
|
+
const factory: ServiceFactory<RootConfigService, "root", "singleton" | "multiton"> & ((options?: Options | undefined) => ServiceFactory<RootConfigService, "root", "singleton" | "multiton">);
|
|
434
434
|
}
|
|
435
435
|
function rootLogger(options?: rootLogger.Options): LoggerService;
|
|
436
436
|
namespace rootLogger {
|
|
437
437
|
type Options = {
|
|
438
438
|
level?: 'none' | 'error' | 'warn' | 'info' | 'debug';
|
|
439
439
|
};
|
|
440
|
-
const factory: ServiceFactory<LoggerService, "root"> & ((options?: Options | undefined) => ServiceFactory<LoggerService, "root">);
|
|
440
|
+
const factory: ServiceFactory<LoggerService, "root", "singleton" | "multiton"> & ((options?: Options | undefined) => ServiceFactory<LoggerService, "root", "singleton" | "multiton">);
|
|
441
441
|
const mock: (partialImpl?: Partial<_backstage_backend_plugin_api.RootLoggerService> | undefined) => ServiceMock<_backstage_backend_plugin_api.RootLoggerService>;
|
|
442
442
|
}
|
|
443
443
|
function tokenManager(): TokenManagerService;
|
|
444
444
|
namespace tokenManager {
|
|
445
|
-
const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<TokenManagerService, "plugin", undefined>;
|
|
445
|
+
const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<TokenManagerService, "plugin", "singleton", undefined>;
|
|
446
446
|
const mock: (partialImpl?: Partial<TokenManagerService> | undefined) => ServiceMock<TokenManagerService>;
|
|
447
447
|
}
|
|
448
448
|
function identity(): IdentityService;
|
|
449
449
|
namespace identity {
|
|
450
|
-
const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<IdentityService, "plugin", undefined>;
|
|
450
|
+
const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<IdentityService, "plugin", "singleton", undefined>;
|
|
451
451
|
const mock: (partialImpl?: Partial<IdentityService> | undefined) => ServiceMock<IdentityService>;
|
|
452
452
|
}
|
|
453
453
|
function auth(options?: {
|
|
@@ -455,12 +455,12 @@ declare namespace mockServices {
|
|
|
455
455
|
disableDefaultAuthPolicy?: boolean;
|
|
456
456
|
}): AuthService;
|
|
457
457
|
namespace auth {
|
|
458
|
-
const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<AuthService, "plugin", undefined>;
|
|
458
|
+
const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<AuthService, "plugin", "singleton", undefined>;
|
|
459
459
|
const mock: (partialImpl?: Partial<AuthService> | undefined) => ServiceMock<AuthService>;
|
|
460
460
|
}
|
|
461
461
|
function discovery(): DiscoveryService;
|
|
462
462
|
namespace discovery {
|
|
463
|
-
const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<DiscoveryService, "plugin", undefined>;
|
|
463
|
+
const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<DiscoveryService, "plugin", "singleton", undefined>;
|
|
464
464
|
const mock: (partialImpl?: Partial<DiscoveryService> | undefined) => ServiceMock<DiscoveryService>;
|
|
465
465
|
}
|
|
466
466
|
/**
|
|
@@ -491,7 +491,7 @@ declare namespace mockServices {
|
|
|
491
491
|
*/
|
|
492
492
|
const factory: ((options?: {
|
|
493
493
|
defaultCredentials?: BackstageCredentials;
|
|
494
|
-
}) => ServiceFactory<HttpAuthService, "plugin">) & ServiceFactory<HttpAuthService, "plugin">;
|
|
494
|
+
}) => ServiceFactory<HttpAuthService, "plugin", "singleton">) & ServiceFactory<HttpAuthService, "plugin", "singleton">;
|
|
495
495
|
const mock: (partialImpl?: Partial<HttpAuthService> | undefined) => ServiceMock<HttpAuthService>;
|
|
496
496
|
}
|
|
497
497
|
/**
|
|
@@ -509,55 +509,55 @@ declare namespace mockServices {
|
|
|
509
509
|
* By default it extracts the user's entity ref from a user principal and
|
|
510
510
|
* returns that as the only ownership entity ref.
|
|
511
511
|
*/
|
|
512
|
-
const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<UserInfoService, "plugin", undefined>;
|
|
512
|
+
const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<UserInfoService, "plugin", "singleton", undefined>;
|
|
513
513
|
const mock: (partialImpl?: Partial<UserInfoService> | undefined) => ServiceMock<UserInfoService>;
|
|
514
514
|
}
|
|
515
515
|
namespace cache {
|
|
516
|
-
const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<_backstage_backend_plugin_api.CacheService, "plugin", undefined>;
|
|
516
|
+
const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<_backstage_backend_plugin_api.CacheService, "plugin", "singleton", undefined>;
|
|
517
517
|
const mock: (partialImpl?: Partial<_backstage_backend_plugin_api.CacheService> | undefined) => ServiceMock<_backstage_backend_plugin_api.CacheService>;
|
|
518
518
|
}
|
|
519
519
|
namespace database {
|
|
520
|
-
const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<_backstage_backend_plugin_api.DatabaseService, "plugin", undefined>;
|
|
520
|
+
const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<_backstage_backend_plugin_api.DatabaseService, "plugin", "singleton", undefined>;
|
|
521
521
|
const mock: (partialImpl?: Partial<_backstage_backend_plugin_api.DatabaseService> | undefined) => ServiceMock<_backstage_backend_plugin_api.DatabaseService>;
|
|
522
522
|
}
|
|
523
523
|
namespace rootHealth {
|
|
524
|
-
const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<_backstage_backend_plugin_api.RootHealthService, "root", undefined>;
|
|
524
|
+
const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<_backstage_backend_plugin_api.RootHealthService, "root", "singleton", undefined>;
|
|
525
525
|
const mock: (partialImpl?: Partial<_backstage_backend_plugin_api.RootHealthService> | undefined) => ServiceMock<_backstage_backend_plugin_api.RootHealthService>;
|
|
526
526
|
}
|
|
527
527
|
namespace httpRouter {
|
|
528
|
-
const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<_backstage_backend_plugin_api.HttpRouterService, "plugin", undefined>;
|
|
528
|
+
const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<_backstage_backend_plugin_api.HttpRouterService, "plugin", "singleton", undefined>;
|
|
529
529
|
const mock: (partialImpl?: Partial<_backstage_backend_plugin_api.HttpRouterService> | undefined) => ServiceMock<_backstage_backend_plugin_api.HttpRouterService>;
|
|
530
530
|
}
|
|
531
531
|
namespace rootHttpRouter {
|
|
532
|
-
const factory: ((options?: _backstage_backend_defaults_rootHttpRouter.RootHttpRouterFactoryOptions | undefined) => ServiceFactory<_backstage_backend_plugin_api.RootHttpRouterService, "root">) & ServiceFactory<_backstage_backend_plugin_api.RootHttpRouterService, "root">;
|
|
532
|
+
const factory: ((options?: _backstage_backend_defaults_rootHttpRouter.RootHttpRouterFactoryOptions | undefined) => ServiceFactory<_backstage_backend_plugin_api.RootHttpRouterService, "root", "singleton">) & ServiceFactory<_backstage_backend_plugin_api.RootHttpRouterService, "root", "singleton">;
|
|
533
533
|
const mock: (partialImpl?: Partial<_backstage_backend_plugin_api.RootHttpRouterService> | undefined) => ServiceMock<_backstage_backend_plugin_api.RootHttpRouterService>;
|
|
534
534
|
}
|
|
535
535
|
namespace lifecycle {
|
|
536
|
-
const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<_backstage_backend_plugin_api.LifecycleService, "plugin", undefined>;
|
|
536
|
+
const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<_backstage_backend_plugin_api.LifecycleService, "plugin", "singleton", undefined>;
|
|
537
537
|
const mock: (partialImpl?: Partial<_backstage_backend_plugin_api.LifecycleService> | undefined) => ServiceMock<_backstage_backend_plugin_api.LifecycleService>;
|
|
538
538
|
}
|
|
539
539
|
namespace logger {
|
|
540
|
-
const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<LoggerService, "plugin", undefined>;
|
|
540
|
+
const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<LoggerService, "plugin", "singleton", undefined>;
|
|
541
541
|
const mock: (partialImpl?: Partial<LoggerService> | undefined) => ServiceMock<LoggerService>;
|
|
542
542
|
}
|
|
543
543
|
namespace permissions {
|
|
544
|
-
const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<_backstage_backend_plugin_api.PermissionsService, "plugin", undefined>;
|
|
544
|
+
const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<_backstage_backend_plugin_api.PermissionsService, "plugin", "singleton", undefined>;
|
|
545
545
|
const mock: (partialImpl?: Partial<_backstage_backend_plugin_api.PermissionsService> | undefined) => ServiceMock<_backstage_backend_plugin_api.PermissionsService>;
|
|
546
546
|
}
|
|
547
547
|
namespace rootLifecycle {
|
|
548
|
-
const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<_backstage_backend_plugin_api.RootLifecycleService, "root", undefined>;
|
|
548
|
+
const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<_backstage_backend_plugin_api.RootLifecycleService, "root", "singleton", undefined>;
|
|
549
549
|
const mock: (partialImpl?: Partial<_backstage_backend_plugin_api.RootLifecycleService> | undefined) => ServiceMock<_backstage_backend_plugin_api.RootLifecycleService>;
|
|
550
550
|
}
|
|
551
551
|
namespace scheduler {
|
|
552
|
-
const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<_backstage_backend_plugin_api.SchedulerService, "plugin", undefined>;
|
|
552
|
+
const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<_backstage_backend_plugin_api.SchedulerService, "plugin", "singleton", undefined>;
|
|
553
553
|
const mock: (partialImpl?: Partial<_backstage_backend_plugin_api.SchedulerService> | undefined) => ServiceMock<_backstage_backend_plugin_api.SchedulerService>;
|
|
554
554
|
}
|
|
555
555
|
namespace urlReader {
|
|
556
|
-
const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<_backstage_backend_plugin_api.UrlReaderService, "plugin", undefined>;
|
|
556
|
+
const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<_backstage_backend_plugin_api.UrlReaderService, "plugin", "singleton", undefined>;
|
|
557
557
|
const mock: (partialImpl?: Partial<_backstage_backend_plugin_api.UrlReaderService> | undefined) => ServiceMock<_backstage_backend_plugin_api.UrlReaderService>;
|
|
558
558
|
}
|
|
559
559
|
namespace events {
|
|
560
|
-
const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<_backstage_plugin_events_node.EventsService, "plugin", undefined>;
|
|
560
|
+
const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<_backstage_plugin_events_node.EventsService, "plugin", "singleton", undefined>;
|
|
561
561
|
const mock: (partialImpl?: Partial<_backstage_plugin_events_node.EventsService> | undefined) => ServiceMock<_backstage_plugin_events_node.EventsService>;
|
|
562
562
|
}
|
|
563
563
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/backend-test-utils",
|
|
3
|
-
"version": "0.4.5-next.
|
|
3
|
+
"version": "0.4.5-next.3",
|
|
4
4
|
"description": "Test helpers library for Backstage backends",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "node-library"
|
|
@@ -42,13 +42,13 @@
|
|
|
42
42
|
"test": "backstage-cli package test"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@backstage/backend-app-api": "^0.8.1-next.
|
|
46
|
-
"@backstage/backend-defaults": "^0.4.2-next.
|
|
47
|
-
"@backstage/backend-plugin-api": "^0.
|
|
45
|
+
"@backstage/backend-app-api": "^0.8.1-next.3",
|
|
46
|
+
"@backstage/backend-defaults": "^0.4.2-next.3",
|
|
47
|
+
"@backstage/backend-plugin-api": "^0.8.0-next.3",
|
|
48
48
|
"@backstage/config": "^1.2.0",
|
|
49
49
|
"@backstage/errors": "^1.2.4",
|
|
50
|
-
"@backstage/plugin-auth-node": "^0.
|
|
51
|
-
"@backstage/plugin-events-node": "^0.3.9-next.
|
|
50
|
+
"@backstage/plugin-auth-node": "^0.5.0-next.3",
|
|
51
|
+
"@backstage/plugin-events-node": "^0.3.9-next.3",
|
|
52
52
|
"@backstage/types": "^1.1.1",
|
|
53
53
|
"@keyv/memcache": "^1.3.5",
|
|
54
54
|
"@keyv/redis": "^2.5.3",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"yn": "^4.0.0"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@backstage/cli": "^0.27.0-next.
|
|
72
|
+
"@backstage/cli": "^0.27.0-next.4",
|
|
73
73
|
"@types/supertest": "^2.0.8",
|
|
74
74
|
"supertest": "^6.1.3"
|
|
75
75
|
},
|