diff --git a/packages/backend-test-utils/api-report.md b/packages/backend-test-utils/api-report.md index ad7ecc04dd..85cdb201ef 100644 --- a/packages/backend-test-utils/api-report.md +++ b/packages/backend-test-utils/api-report.md @@ -5,8 +5,10 @@ ```ts import { Backend } from '@backstage/backend-app-api'; import { BackendFeature } from '@backstage/backend-plugin-api'; +import { ConfigService } from '@backstage/backend-plugin-api'; import { ExtendedHttpServer } from '@backstage/backend-app-api'; import { ExtensionPoint } from '@backstage/backend-plugin-api'; +import { JsonObject } from '@backstage/types'; import { Knex } from 'knex'; import { ServiceFactory } from '@backstage/backend-plugin-api'; import { ServiceRef } from '@backstage/backend-plugin-api'; @@ -14,6 +16,15 @@ import { ServiceRef } from '@backstage/backend-plugin-api'; // @public (undocumented) export function isDockerDisabledForTests(): boolean; +// @public (undocumented) +export const mockConfigFactory: ( + options?: + | { + data?: JsonObject | undefined; + } + | undefined, +) => ServiceFactory; + // @public export function setupRequestMockHandlers(worker: { listen: (t: any) => void; diff --git a/packages/backend-test-utils/src/next/implementations/index.ts b/packages/backend-test-utils/src/next/implementations/index.ts index 2068aebec5..55f417f8df 100644 --- a/packages/backend-test-utils/src/next/implementations/index.ts +++ b/packages/backend-test-utils/src/next/implementations/index.ts @@ -13,5 +13,4 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -export { mockTokenManagerFactory } from './mockTokenManagerService'; export { mockConfigFactory } from './mockConfigService'; diff --git a/packages/backend-test-utils/src/next/index.ts b/packages/backend-test-utils/src/next/index.ts index 9bb5431772..9f9edfd837 100644 --- a/packages/backend-test-utils/src/next/index.ts +++ b/packages/backend-test-utils/src/next/index.ts @@ -15,3 +15,4 @@ */ export * from './wiring'; +export * from './implementations'; diff --git a/packages/backend-test-utils/src/next/wiring/TestBackend.ts b/packages/backend-test-utils/src/next/wiring/TestBackend.ts index 00c38240a3..8fe489750a 100644 --- a/packages/backend-test-utils/src/next/wiring/TestBackend.ts +++ b/packages/backend-test-utils/src/next/wiring/TestBackend.ts @@ -42,7 +42,8 @@ import { coreServices, } from '@backstage/backend-plugin-api'; -import { mockConfigFactory, mockTokenManagerFactory } from '../implementations'; +import { mockConfigFactory } from '../implementations/mockConfigService'; +import { mockTokenManagerFactory } from '../implementations/mockTokenManagerService'; import { ConfigReader } from '@backstage/config'; import express from 'express'; diff --git a/plugins/catalog-backend-module-bitbucket-cloud/src/service/BitbucketCloudEntityProviderCatalogModule.test.ts b/plugins/catalog-backend-module-bitbucket-cloud/src/service/BitbucketCloudEntityProviderCatalogModule.test.ts index 83e657bcfe..d44281600c 100644 --- a/plugins/catalog-backend-module-bitbucket-cloud/src/service/BitbucketCloudEntityProviderCatalogModule.test.ts +++ b/plugins/catalog-backend-module-bitbucket-cloud/src/service/BitbucketCloudEntityProviderCatalogModule.test.ts @@ -14,18 +14,15 @@ * limitations under the License. */ -import { ConfigReader } from '@backstage/config'; -import { - getVoidLogger, - PluginEndpointDiscovery, - TokenManager, -} from '@backstage/backend-common'; import { coreServices } from '@backstage/backend-plugin-api'; import { PluginTaskScheduler, TaskScheduleDefinition, } from '@backstage/backend-tasks'; -import { startTestBackend } from '@backstage/backend-test-utils'; +import { + startTestBackend, + mockConfigFactory, +} from '@backstage/backend-test-utils'; import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node'; import { eventsExtensionPoint } from '@backstage/plugin-events-node'; import { Duration } from 'luxon'; @@ -55,22 +52,6 @@ describe('bitbucketCloudEntityProviderCatalogModule', () => { return runner; }, } as unknown as PluginTaskScheduler; - const discovery = jest.fn() as any as PluginEndpointDiscovery; - const tokenManager = jest.fn() as any as TokenManager; - - const config = new ConfigReader({ - catalog: { - providers: { - bitbucketCloud: { - schedule: { - frequency: 'P1M', - timeout: 'PT3M', - }, - workspace: 'test-ws', - }, - }, - }, - }); await startTestBackend({ extensionPoints: [ @@ -78,11 +59,22 @@ describe('bitbucketCloudEntityProviderCatalogModule', () => { [eventsExtensionPoint, eventsExtensionPointImpl], ], services: [ - [coreServices.config, config], - [coreServices.discovery, discovery], - [coreServices.logger, getVoidLogger()], + mockConfigFactory({ + data: { + catalog: { + providers: { + bitbucketCloud: { + schedule: { + frequency: 'P1M', + timeout: 'PT3M', + }, + workspace: 'test-ws', + }, + }, + }, + }, + }), [coreServices.scheduler, scheduler], - [coreServices.tokenManager, tokenManager], ], features: [bitbucketCloudEntityProviderCatalogModule()], });