@backstage/backend-test-utils 0.1.26-next.3 → 0.1.27

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 CHANGED
@@ -1,5 +1,36 @@
1
1
  # @backstage/backend-test-utils
2
2
 
3
+ ## 0.1.27
4
+
5
+ ### Patch Changes
6
+
7
+ - 0599732ec0: Refactored experimental backend system with new type names.
8
+ - 56e1b4b89c: Added alpha test helpers for the new experimental backend system.
9
+ - Updated dependencies
10
+ - @backstage/cli@0.18.1
11
+ - @backstage/backend-common@0.15.0
12
+ - @backstage/backend-app-api@0.2.0
13
+ - @backstage/backend-plugin-api@0.1.1
14
+
15
+ ## 0.1.27-next.0
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies
20
+ - @backstage/backend-common@0.15.0-next.0
21
+ - @backstage/cli@0.18.1-next.0
22
+
23
+ ## 0.1.26
24
+
25
+ ### Patch Changes
26
+
27
+ - a70869e775: Updated dependency `msw` to `^0.43.0`.
28
+ - 8006d0f9bf: Updated dependency `msw` to `^0.44.0`.
29
+ - 679b32172e: Updated dependency `knex` to `^2.0.0`.
30
+ - Updated dependencies
31
+ - @backstage/backend-common@0.14.1
32
+ - @backstage/cli@0.18.0
33
+
3
34
  ## 0.1.26-next.3
4
35
 
5
36
  ### Patch Changes
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "@backstage/backend-test-utils",
3
+ "version": "0.1.27",
4
+ "main": "../dist/index.cjs.js",
5
+ "types": "../dist/index.alpha.d.ts"
6
+ }
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Test helpers library for Backstage backends
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+
7
+ import { AnyServiceFactory } from '@backstage/backend-plugin-api';
8
+ import { BackendFeature } from '@backstage/backend-plugin-api';
9
+ import { ExtensionPoint } from '@backstage/backend-plugin-api';
10
+ import { Knex } from 'knex';
11
+ import { ServiceRef } from '@backstage/backend-plugin-api';
12
+
13
+ /** @public */
14
+ export declare function isDockerDisabledForTests(): boolean;
15
+
16
+ /**
17
+ * Sets up handlers for request mocking
18
+ * @public
19
+ * @param worker - service worker
20
+ */
21
+ export declare function setupRequestMockHandlers(worker: {
22
+ listen: (t: any) => void;
23
+ close: () => void;
24
+ resetHandlers: () => void;
25
+ }): void;
26
+
27
+ /** @alpha */
28
+ export declare function startTestBackend<TServices extends any[], TExtensionPoints extends any[]>(options: TestBackendOptions<TServices, TExtensionPoints>): Promise<void>;
29
+
30
+ /** @alpha */
31
+ export declare interface TestBackendOptions<TServices extends any[], TExtensionPoints extends any[]> {
32
+ services?: readonly [
33
+ ...{
34
+ [index in keyof TServices]: AnyServiceFactory | [ServiceRef<TServices[index]>, Partial<TServices[index]>];
35
+ }
36
+ ];
37
+ extensionPoints?: readonly [
38
+ ...{
39
+ [index in keyof TExtensionPoints]: [
40
+ ExtensionPoint<TExtensionPoints[index]>,
41
+ Partial<TExtensionPoints[index]>
42
+ ];
43
+ }
44
+ ];
45
+ features?: BackendFeature[];
46
+ }
47
+
48
+ /**
49
+ * The possible databases to test against.
50
+ *
51
+ * @public
52
+ */
53
+ export declare type TestDatabaseId = 'POSTGRES_13' | 'POSTGRES_9' | 'MYSQL_8' | 'SQLITE_3';
54
+
55
+ /**
56
+ * Encapsulates the creation of ephemeral test database instances for use
57
+ * inside unit or integration tests.
58
+ *
59
+ * @public
60
+ */
61
+ export declare class TestDatabases {
62
+ private readonly instanceById;
63
+ private readonly supportedIds;
64
+ /**
65
+ * Creates an empty `TestDatabases` instance, and sets up Jest to clean up
66
+ * all of its acquired resources after all tests finish.
67
+ *
68
+ * You typically want to create just a single instance like this at the top
69
+ * of your test file or `describe` block, and then call `init` many times on
70
+ * that instance inside the individual tests. Spinning up a "physical"
71
+ * database instance takes a considerable amount of time, slowing down tests.
72
+ * But initializing a new logical database inside that instance using `init`
73
+ * is very fast.
74
+ */
75
+ static create(options?: {
76
+ ids?: TestDatabaseId[];
77
+ disableDocker?: boolean;
78
+ }): TestDatabases;
79
+ private constructor();
80
+ supports(id: TestDatabaseId): boolean;
81
+ eachSupportedId(): [TestDatabaseId][];
82
+ /**
83
+ * Returns a fresh, unique, empty logical database on an instance of the
84
+ * given database ID platform.
85
+ *
86
+ * @param id - The ID of the database platform to use, e.g. 'POSTGRES_13'
87
+ * @returns A `Knex` connection object
88
+ */
89
+ init(id: TestDatabaseId): Promise<Knex>;
90
+ private initAny;
91
+ private initPostgres;
92
+ private initMysql;
93
+ private initSqlite;
94
+ private shutdown;
95
+ }
96
+
97
+ export { }
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Test helpers library for Backstage backends
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+
7
+ import { AnyServiceFactory } from '@backstage/backend-plugin-api';
8
+ import { BackendFeature } from '@backstage/backend-plugin-api';
9
+ import { ExtensionPoint } from '@backstage/backend-plugin-api';
10
+ import { Knex } from 'knex';
11
+ import { ServiceRef } from '@backstage/backend-plugin-api';
12
+
13
+ /** @public */
14
+ export declare function isDockerDisabledForTests(): boolean;
15
+
16
+ /**
17
+ * Sets up handlers for request mocking
18
+ * @public
19
+ * @param worker - service worker
20
+ */
21
+ export declare function setupRequestMockHandlers(worker: {
22
+ listen: (t: any) => void;
23
+ close: () => void;
24
+ resetHandlers: () => void;
25
+ }): void;
26
+
27
+ /* Excluded from this release type: startTestBackend */
28
+
29
+ /* Excluded from this release type: TestBackendOptions */
30
+
31
+ /**
32
+ * The possible databases to test against.
33
+ *
34
+ * @public
35
+ */
36
+ export declare type TestDatabaseId = 'POSTGRES_13' | 'POSTGRES_9' | 'MYSQL_8' | 'SQLITE_3';
37
+
38
+ /**
39
+ * Encapsulates the creation of ephemeral test database instances for use
40
+ * inside unit or integration tests.
41
+ *
42
+ * @public
43
+ */
44
+ export declare class TestDatabases {
45
+ private readonly instanceById;
46
+ private readonly supportedIds;
47
+ /**
48
+ * Creates an empty `TestDatabases` instance, and sets up Jest to clean up
49
+ * all of its acquired resources after all tests finish.
50
+ *
51
+ * You typically want to create just a single instance like this at the top
52
+ * of your test file or `describe` block, and then call `init` many times on
53
+ * that instance inside the individual tests. Spinning up a "physical"
54
+ * database instance takes a considerable amount of time, slowing down tests.
55
+ * But initializing a new logical database inside that instance using `init`
56
+ * is very fast.
57
+ */
58
+ static create(options?: {
59
+ ids?: TestDatabaseId[];
60
+ disableDocker?: boolean;
61
+ }): TestDatabases;
62
+ private constructor();
63
+ supports(id: TestDatabaseId): boolean;
64
+ eachSupportedId(): [TestDatabaseId][];
65
+ /**
66
+ * Returns a fresh, unique, empty logical database on an instance of the
67
+ * given database ID platform.
68
+ *
69
+ * @param id - The ID of the database platform to use, e.g. 'POSTGRES_13'
70
+ * @returns A `Knex` connection object
71
+ */
72
+ init(id: TestDatabaseId): Promise<Knex>;
73
+ private initAny;
74
+ private initPostgres;
75
+ private initMysql;
76
+ private initSqlite;
77
+ private shutdown;
78
+ }
79
+
80
+ export { }
package/dist/index.cjs.js CHANGED
@@ -7,6 +7,8 @@ var config = require('@backstage/config');
7
7
  var crypto = require('crypto');
8
8
  var createConnection = require('knex');
9
9
  var uuid = require('uuid');
10
+ var backendAppApi = require('@backstage/backend-app-api');
11
+ var backendPluginApi = require('@backstage/backend-plugin-api');
10
12
 
11
13
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
12
14
 
@@ -47,7 +49,9 @@ async function waitForMysqlReady(connection) {
47
49
  }
48
50
  } catch (e) {
49
51
  if (Date.now() - startTime > 3e4) {
50
- throw new Error(`Timed out waiting for the database to be ready for connections, ${e}`);
52
+ throw new Error(
53
+ `Timed out waiting for the database to be ready for connections, ${e}`
54
+ );
51
55
  }
52
56
  }
53
57
  await new Promise((resolve) => setTimeout(resolve, 100));
@@ -83,7 +87,9 @@ async function waitForPostgresReady(connection) {
83
87
  }
84
88
  } catch (e) {
85
89
  if (Date.now() - startTime > 3e4) {
86
- throw new Error(`Timed out waiting for the database to be ready for connections, ${e}`);
90
+ throw new Error(
91
+ `Timed out waiting for the database to be ready for connections, ${e}`
92
+ );
87
93
  }
88
94
  }
89
95
  await new Promise((resolve) => setTimeout(resolve, 100));
@@ -137,7 +143,11 @@ class TestDatabases {
137
143
  ids: Object.keys(allDatabases),
138
144
  disableDocker: isDockerDisabledForTests()
139
145
  };
140
- const { ids, disableDocker } = Object.assign({}, defaultOptions, options != null ? options : {});
146
+ const { ids, disableDocker } = Object.assign(
147
+ {},
148
+ defaultOptions,
149
+ options != null ? options : {}
150
+ );
141
151
  const supportedIds = ids.filter((id) => {
142
152
  const properties = allDatabases[id];
143
153
  if (!properties) {
@@ -176,11 +186,15 @@ class TestDatabases {
176
186
  const properties = allDatabases[id];
177
187
  if (!properties) {
178
188
  const candidates = Object.keys(allDatabases).join(", ");
179
- throw new Error(`Unknown test database ${id}, possible values are ${candidates}`);
189
+ throw new Error(
190
+ `Unknown test database ${id}, possible values are ${candidates}`
191
+ );
180
192
  }
181
193
  if (!this.supportedIds.includes(id)) {
182
194
  const candidates = this.supportedIds.join(", ");
183
- throw new Error(`Unsupported test database ${id} for this environment, possible values are ${candidates}`);
195
+ throw new Error(
196
+ `Unsupported test database ${id} for this environment, possible values are ${candidates}`
197
+ );
184
198
  }
185
199
  let instance = this.instanceById.get(id);
186
200
  if (!instance) {
@@ -197,14 +211,16 @@ class TestDatabases {
197
211
  if (envVarName) {
198
212
  const connectionString = process.env[envVarName];
199
213
  if (connectionString) {
200
- const databaseManager = backendCommon.DatabaseManager.fromConfig(new config.ConfigReader({
201
- backend: {
202
- database: {
203
- client: properties.driver,
204
- connection: connectionString
214
+ const databaseManager = backendCommon.DatabaseManager.fromConfig(
215
+ new config.ConfigReader({
216
+ backend: {
217
+ database: {
218
+ client: properties.driver,
219
+ connection: connectionString
220
+ }
205
221
  }
206
- }
207
- }));
222
+ })
223
+ );
208
224
  return {
209
225
  databaseManager,
210
226
  connections: []
@@ -225,15 +241,19 @@ class TestDatabases {
225
241
  }
226
242
  }
227
243
  async initPostgres(properties) {
228
- const { host, port, user, password, stop } = await startPostgresContainer(properties.dockerImageName);
229
- const databaseManager = backendCommon.DatabaseManager.fromConfig(new config.ConfigReader({
230
- backend: {
231
- database: {
232
- client: "pg",
233
- connection: { host, port, user, password }
244
+ const { host, port, user, password, stop } = await startPostgresContainer(
245
+ properties.dockerImageName
246
+ );
247
+ const databaseManager = backendCommon.DatabaseManager.fromConfig(
248
+ new config.ConfigReader({
249
+ backend: {
250
+ database: {
251
+ client: "pg",
252
+ connection: { host, port, user, password }
253
+ }
234
254
  }
235
- }
236
- }));
255
+ })
256
+ );
237
257
  return {
238
258
  stopContainer: stop,
239
259
  databaseManager,
@@ -241,15 +261,19 @@ class TestDatabases {
241
261
  };
242
262
  }
243
263
  async initMysql(properties) {
244
- const { host, port, user, password, stop } = await startMysqlContainer(properties.dockerImageName);
245
- const databaseManager = backendCommon.DatabaseManager.fromConfig(new config.ConfigReader({
246
- backend: {
247
- database: {
248
- client: "mysql2",
249
- connection: { host, port, user, password }
264
+ const { host, port, user, password, stop } = await startMysqlContainer(
265
+ properties.dockerImageName
266
+ );
267
+ const databaseManager = backendCommon.DatabaseManager.fromConfig(
268
+ new config.ConfigReader({
269
+ backend: {
270
+ database: {
271
+ client: "mysql2",
272
+ connection: { host, port, user, password }
273
+ }
250
274
  }
251
- }
252
- }));
275
+ })
276
+ );
253
277
  return {
254
278
  stopContainer: stop,
255
279
  databaseManager,
@@ -257,14 +281,16 @@ class TestDatabases {
257
281
  };
258
282
  }
259
283
  async initSqlite(properties) {
260
- const databaseManager = backendCommon.DatabaseManager.fromConfig(new config.ConfigReader({
261
- backend: {
262
- database: {
263
- client: properties.driver,
264
- connection: ":memory:"
284
+ const databaseManager = backendCommon.DatabaseManager.fromConfig(
285
+ new config.ConfigReader({
286
+ backend: {
287
+ database: {
288
+ client: properties.driver,
289
+ connection: ":memory:"
290
+ }
265
291
  }
266
- }
267
- }));
292
+ })
293
+ );
268
294
  return {
269
295
  databaseManager,
270
296
  connections: []
@@ -272,16 +298,18 @@ class TestDatabases {
272
298
  }
273
299
  async shutdown() {
274
300
  const instances = [...this.instanceById.values()];
275
- await Promise.all(instances.map(async ({ stopContainer, connections }) => {
276
- try {
277
- await Promise.all(connections.map((c) => c.destroy()));
278
- } catch {
279
- }
280
- try {
281
- await (stopContainer == null ? void 0 : stopContainer());
282
- } catch {
283
- }
284
- }));
301
+ await Promise.all(
302
+ instances.map(async ({ stopContainer, connections }) => {
303
+ try {
304
+ await Promise.all(connections.map((c) => c.destroy()));
305
+ } catch {
306
+ }
307
+ try {
308
+ await (stopContainer == null ? void 0 : stopContainer());
309
+ } catch {
310
+ }
311
+ })
312
+ );
285
313
  }
286
314
  }
287
315
 
@@ -291,7 +319,45 @@ function setupRequestMockHandlers(worker) {
291
319
  afterEach(() => worker.resetHandlers());
292
320
  }
293
321
 
322
+ async function startTestBackend(options) {
323
+ const {
324
+ services = [],
325
+ extensionPoints = [],
326
+ features = [],
327
+ ...otherOptions
328
+ } = options;
329
+ const factories = services.map((serviceDef) => {
330
+ if (Array.isArray(serviceDef)) {
331
+ return backendPluginApi.createServiceFactory({
332
+ service: serviceDef[0],
333
+ deps: {},
334
+ factory: async () => async () => serviceDef[1]
335
+ });
336
+ }
337
+ return serviceDef;
338
+ });
339
+ const backend = backendAppApi.createSpecializedBackend({
340
+ ...otherOptions,
341
+ services: factories
342
+ });
343
+ backend.add({
344
+ id: `---test-extension-point-registrar`,
345
+ register(reg) {
346
+ for (const [ref, impl] of extensionPoints) {
347
+ reg.registerExtensionPoint(ref, impl);
348
+ }
349
+ reg.registerInit({ deps: {}, async init() {
350
+ } });
351
+ }
352
+ });
353
+ for (const feature of features) {
354
+ backend.add(feature);
355
+ }
356
+ await backend.start();
357
+ }
358
+
294
359
  exports.TestDatabases = TestDatabases;
295
360
  exports.isDockerDisabledForTests = isDockerDisabledForTests;
296
361
  exports.setupRequestMockHandlers = setupRequestMockHandlers;
362
+ exports.startTestBackend = startTestBackend;
297
363
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/util/isDockerDisabledForTests.ts","../src/database/startMysqlContainer.ts","../src/database/startPostgresContainer.ts","../src/database/types.ts","../src/database/TestDatabases.ts","../src/msw/setupRequestMockHandlers.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** @public */\nexport function isDockerDisabledForTests() {\n // If we are not running in continuous integration, the default is to skip\n // the (relatively heavy, long running) docker based tests. If you want to\n // still run local tests for all databases, just pass either the CI=1 env\n // parameter to your test runner, or individual connection strings per\n // database.\n return (\n Boolean(process.env.BACKSTAGE_TEST_DISABLE_DOCKER) ||\n !Boolean(process.env.CI)\n );\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport createConnection, { Knex } from 'knex';\nimport { v4 as uuid } from 'uuid';\n\nasync function waitForMysqlReady(\n connection: Knex.MySqlConnectionConfig,\n): Promise<void> {\n const startTime = Date.now();\n const db = createConnection({ client: 'mysql2', connection });\n\n try {\n for (;;) {\n try {\n const result = await db.select(db.raw('version() AS version'));\n if (result[0]?.version) {\n return;\n }\n } catch (e) {\n if (Date.now() - startTime > 30_000) {\n throw new Error(\n `Timed out waiting for the database to be ready for connections, ${e}`,\n );\n }\n }\n\n await new Promise(resolve => setTimeout(resolve, 100));\n }\n } finally {\n db.destroy();\n }\n}\n\nexport async function startMysqlContainer(image: string) {\n const user = 'root';\n const password = uuid();\n\n // Lazy-load to avoid side-effect of importing testcontainers\n const { GenericContainer } = await import('testcontainers');\n\n const container = await new GenericContainer(image)\n .withExposedPorts(3306)\n .withEnv('MYSQL_ROOT_PASSWORD', password)\n .withTmpFs({ '/var/lib/mysql': 'rw' })\n .start();\n\n const host = container.getHost();\n const port = container.getMappedPort(3306);\n const stop = async () => {\n await container.stop({ timeout: 10_000 });\n };\n\n await waitForMysqlReady({ host, port, user, password });\n\n return { host, port, user, password, stop };\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport createConnection, { Knex } from 'knex';\nimport { v4 as uuid } from 'uuid';\n\nasync function waitForPostgresReady(\n connection: Knex.PgConnectionConfig,\n): Promise<void> {\n const startTime = Date.now();\n const db = createConnection({ client: 'pg', connection });\n\n try {\n for (;;) {\n try {\n const result = await db.select(db.raw('version()'));\n if (Array.isArray(result) && result[0]?.version) {\n return;\n }\n } catch (e) {\n if (Date.now() - startTime > 30_000) {\n throw new Error(\n `Timed out waiting for the database to be ready for connections, ${e}`,\n );\n }\n }\n\n await new Promise(resolve => setTimeout(resolve, 100));\n }\n } finally {\n db.destroy();\n }\n}\n\nexport async function startPostgresContainer(image: string) {\n const user = 'postgres';\n const password = uuid();\n\n // Lazy-load to avoid side-effect of importing testcontainers\n const { GenericContainer } = await import('testcontainers');\n\n const container = await new GenericContainer(image)\n .withExposedPorts(5432)\n .withEnv('POSTGRES_PASSWORD', password)\n .withTmpFs({ '/var/lib/postgresql/data': 'rw' })\n .start();\n\n const host = container.getHost();\n const port = container.getMappedPort(5432);\n const stop = async () => {\n await container.stop({ timeout: 10_000 });\n };\n\n await waitForPostgresReady({ host, port, user, password });\n\n return { host, port, user, password, stop };\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DatabaseManager } from '@backstage/backend-common';\nimport { Knex } from 'knex';\n\n/**\n * The possible databases to test against.\n *\n * @public\n */\nexport type TestDatabaseId =\n | 'POSTGRES_13'\n | 'POSTGRES_9'\n | 'MYSQL_8'\n | 'SQLITE_3';\n\nexport type TestDatabaseProperties = {\n name: string;\n driver: string;\n dockerImageName?: string;\n connectionStringEnvironmentVariableName?: string;\n};\n\nexport type Instance = {\n stopContainer?: () => Promise<void>;\n databaseManager: DatabaseManager;\n connections: Array<Knex>;\n};\n\nexport const allDatabases: Record<TestDatabaseId, TestDatabaseProperties> =\n Object.freeze({\n POSTGRES_13: {\n name: 'Postgres 13.x',\n driver: 'pg',\n dockerImageName: 'postgres:13',\n connectionStringEnvironmentVariableName:\n 'BACKSTAGE_TEST_DATABASE_POSTGRES13_CONNECTION_STRING',\n },\n POSTGRES_9: {\n name: 'Postgres 9.x',\n driver: 'pg',\n dockerImageName: 'postgres:9',\n connectionStringEnvironmentVariableName:\n 'BACKSTAGE_TEST_DATABASE_POSTGRES9_CONNECTION_STRING',\n },\n MYSQL_8: {\n name: 'MySQL 8.x',\n driver: 'mysql2',\n dockerImageName: 'mysql:8',\n connectionStringEnvironmentVariableName:\n 'BACKSTAGE_TEST_DATABASE_MYSQL8_CONNECTION_STRING',\n },\n SQLITE_3: {\n name: 'SQLite 3.x',\n driver: 'better-sqlite3',\n },\n });\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DatabaseManager } from '@backstage/backend-common';\nimport { ConfigReader } from '@backstage/config';\nimport { randomBytes } from 'crypto';\nimport { Knex } from 'knex';\nimport { isDockerDisabledForTests } from '../util/isDockerDisabledForTests';\nimport { startMysqlContainer } from './startMysqlContainer';\nimport { startPostgresContainer } from './startPostgresContainer';\nimport {\n allDatabases,\n Instance,\n TestDatabaseId,\n TestDatabaseProperties,\n} from './types';\n\n/**\n * Encapsulates the creation of ephemeral test database instances for use\n * inside unit or integration tests.\n *\n * @public\n */\nexport class TestDatabases {\n private readonly instanceById: Map<string, Instance>;\n private readonly supportedIds: TestDatabaseId[];\n\n /**\n * Creates an empty `TestDatabases` instance, and sets up Jest to clean up\n * all of its acquired resources after all tests finish.\n *\n * You typically want to create just a single instance like this at the top\n * of your test file or `describe` block, and then call `init` many times on\n * that instance inside the individual tests. Spinning up a \"physical\"\n * database instance takes a considerable amount of time, slowing down tests.\n * But initializing a new logical database inside that instance using `init`\n * is very fast.\n */\n static create(options?: {\n ids?: TestDatabaseId[];\n disableDocker?: boolean;\n }): TestDatabases {\n const defaultOptions = {\n ids: Object.keys(allDatabases) as TestDatabaseId[],\n disableDocker: isDockerDisabledForTests(),\n };\n\n const { ids, disableDocker } = Object.assign(\n {},\n defaultOptions,\n options ?? {},\n );\n\n const supportedIds = ids.filter(id => {\n const properties = allDatabases[id];\n if (!properties) {\n return false;\n }\n // If the caller has set up the env with an explicit connection string,\n // we'll assume that this database will work\n if (\n properties.connectionStringEnvironmentVariableName &&\n process.env[properties.connectionStringEnvironmentVariableName]\n ) {\n return true;\n }\n // If the database doesn't require docker at all, there's nothing to worry\n // about\n if (!properties.dockerImageName) {\n return true;\n }\n // If the database requires docker, but docker is disabled, we will fail.\n if (disableDocker) {\n return false;\n }\n return true;\n });\n\n const databases = new TestDatabases(supportedIds);\n\n if (supportedIds.length > 0) {\n afterAll(async () => {\n await databases.shutdown();\n });\n }\n\n return databases;\n }\n\n private constructor(supportedIds: TestDatabaseId[]) {\n this.instanceById = new Map();\n this.supportedIds = supportedIds;\n }\n\n supports(id: TestDatabaseId): boolean {\n return this.supportedIds.includes(id);\n }\n\n eachSupportedId(): [TestDatabaseId][] {\n return this.supportedIds.map(id => [id]);\n }\n\n /**\n * Returns a fresh, unique, empty logical database on an instance of the\n * given database ID platform.\n *\n * @param id - The ID of the database platform to use, e.g. 'POSTGRES_13'\n * @returns A `Knex` connection object\n */\n async init(id: TestDatabaseId): Promise<Knex> {\n const properties = allDatabases[id];\n if (!properties) {\n const candidates = Object.keys(allDatabases).join(', ');\n throw new Error(\n `Unknown test database ${id}, possible values are ${candidates}`,\n );\n }\n if (!this.supportedIds.includes(id)) {\n const candidates = this.supportedIds.join(', ');\n throw new Error(\n `Unsupported test database ${id} for this environment, possible values are ${candidates}`,\n );\n }\n\n let instance: Instance | undefined = this.instanceById.get(id);\n\n // Ensure that a testcontainers instance is up for this ID\n if (!instance) {\n instance = await this.initAny(properties);\n this.instanceById.set(id, instance);\n }\n\n // Ensure that a unique logical database is created in the instance\n const connection = await instance.databaseManager\n .forPlugin(`db${randomBytes(16).toString('hex')}`)\n .getClient();\n\n instance.connections.push(connection);\n\n return connection;\n }\n\n private async initAny(properties: TestDatabaseProperties): Promise<Instance> {\n // Use the connection string if provided\n if (properties.driver === 'pg' || properties.driver === 'mysql2') {\n const envVarName = properties.connectionStringEnvironmentVariableName;\n if (envVarName) {\n const connectionString = process.env[envVarName];\n if (connectionString) {\n const databaseManager = DatabaseManager.fromConfig(\n new ConfigReader({\n backend: {\n database: {\n client: properties.driver,\n connection: connectionString,\n },\n },\n }),\n );\n return {\n databaseManager,\n connections: [],\n };\n }\n }\n }\n\n // Otherwise start a container for the purpose\n switch (properties.driver) {\n case 'pg':\n return this.initPostgres(properties);\n case 'mysql2':\n return this.initMysql(properties);\n case 'better-sqlite3':\n case 'sqlite3':\n return this.initSqlite(properties);\n default:\n throw new Error(`Unknown database driver ${properties.driver}`);\n }\n }\n\n private async initPostgres(\n properties: TestDatabaseProperties,\n ): Promise<Instance> {\n const { host, port, user, password, stop } = await startPostgresContainer(\n properties.dockerImageName!,\n );\n\n const databaseManager = DatabaseManager.fromConfig(\n new ConfigReader({\n backend: {\n database: {\n client: 'pg',\n connection: { host, port, user, password },\n },\n },\n }),\n );\n\n return {\n stopContainer: stop,\n databaseManager,\n connections: [],\n };\n }\n\n private async initMysql(\n properties: TestDatabaseProperties,\n ): Promise<Instance> {\n const { host, port, user, password, stop } = await startMysqlContainer(\n properties.dockerImageName!,\n );\n\n const databaseManager = DatabaseManager.fromConfig(\n new ConfigReader({\n backend: {\n database: {\n client: 'mysql2',\n connection: { host, port, user, password },\n },\n },\n }),\n );\n\n return {\n stopContainer: stop,\n databaseManager,\n connections: [],\n };\n }\n\n private async initSqlite(\n properties: TestDatabaseProperties,\n ): Promise<Instance> {\n const databaseManager = DatabaseManager.fromConfig(\n new ConfigReader({\n backend: {\n database: {\n client: properties.driver,\n connection: ':memory:',\n },\n },\n }),\n );\n\n return {\n databaseManager,\n connections: [],\n };\n }\n\n private async shutdown() {\n const instances = [...this.instanceById.values()];\n await Promise.all(\n instances.map(async ({ stopContainer, connections }) => {\n try {\n await Promise.all(connections.map(c => c.destroy()));\n } catch {\n // ignore\n }\n try {\n await stopContainer?.();\n } catch {\n // ignore\n }\n }),\n );\n }\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Sets up handlers for request mocking\n * @public\n * @param worker - service worker\n */\nexport function setupRequestMockHandlers(worker: {\n listen: (t: any) => void;\n close: () => void;\n resetHandlers: () => void;\n}) {\n beforeAll(() => worker.listen({ onUnhandledRequest: 'error' }));\n afterAll(() => worker.close());\n afterEach(() => worker.resetHandlers());\n}\n"],"names":["createConnection","uuid","randomBytes","DatabaseManager","ConfigReader"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,SAAS,wBAAwB,GAAG;AAC3C,EAAE,OAAO,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AACxF;;ACAA,eAAe,iBAAiB,CAAC,UAAU,EAAE;AAC7C,EAAE,IAAI,EAAE,CAAC;AACT,EAAE,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;AAC/B,EAAE,MAAM,EAAE,GAAGA,oCAAgB,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAC;AAChE,EAAE,IAAI;AACN,IAAI,WAAW;AACf,MAAM,IAAI;AACV,QAAQ,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC,CAAC;AACvE,QAAQ,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,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MAAM,IAAI;AACV,QAAQ,MAAM,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;AAC/D,OAAO,CAAC,MAAM;AACd,OAAO;AACP,MAAM,IAAI;AACV,QAAQ,OAAO,aAAa,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,aAAa,EAAE,CAAC,CAAC;AACjE,OAAO,CAAC,MAAM;AACd,OAAO;AACP,KAAK,CAAC,CAAC,CAAC;AACR,GAAG;AACH;;ACjKO,SAAS,wBAAwB,CAAC,MAAM,EAAE;AACjD,EAAE,SAAS,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC,EAAE,kBAAkB,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;AAClE,EAAE,QAAQ,CAAC,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;AACjC,EAAE,SAAS,CAAC,MAAM,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC;AAC1C;;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/util/isDockerDisabledForTests.ts","../src/database/startMysqlContainer.ts","../src/database/startPostgresContainer.ts","../src/database/types.ts","../src/database/TestDatabases.ts","../src/msw/setupRequestMockHandlers.ts","../src/next/wiring/TestBackend.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** @public */\nexport function isDockerDisabledForTests() {\n // If we are not running in continuous integration, the default is to skip\n // the (relatively heavy, long running) docker based tests. If you want to\n // still run local tests for all databases, just pass either the CI=1 env\n // parameter to your test runner, or individual connection strings per\n // database.\n return (\n Boolean(process.env.BACKSTAGE_TEST_DISABLE_DOCKER) ||\n !Boolean(process.env.CI)\n );\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport createConnection, { Knex } from 'knex';\nimport { v4 as uuid } from 'uuid';\n\nasync function waitForMysqlReady(\n connection: Knex.MySqlConnectionConfig,\n): Promise<void> {\n const startTime = Date.now();\n const db = createConnection({ client: 'mysql2', connection });\n\n try {\n for (;;) {\n try {\n const result = await db.select(db.raw('version() AS version'));\n if (result[0]?.version) {\n return;\n }\n } catch (e) {\n if (Date.now() - startTime > 30_000) {\n throw new Error(\n `Timed out waiting for the database to be ready for connections, ${e}`,\n );\n }\n }\n\n await new Promise(resolve => setTimeout(resolve, 100));\n }\n } finally {\n db.destroy();\n }\n}\n\nexport async function startMysqlContainer(image: string) {\n const user = 'root';\n const password = uuid();\n\n // Lazy-load to avoid side-effect of importing testcontainers\n const { GenericContainer } = await import('testcontainers');\n\n const container = await new GenericContainer(image)\n .withExposedPorts(3306)\n .withEnv('MYSQL_ROOT_PASSWORD', password)\n .withTmpFs({ '/var/lib/mysql': 'rw' })\n .start();\n\n const host = container.getHost();\n const port = container.getMappedPort(3306);\n const stop = async () => {\n await container.stop({ timeout: 10_000 });\n };\n\n await waitForMysqlReady({ host, port, user, password });\n\n return { host, port, user, password, stop };\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport createConnection, { Knex } from 'knex';\nimport { v4 as uuid } from 'uuid';\n\nasync function waitForPostgresReady(\n connection: Knex.PgConnectionConfig,\n): Promise<void> {\n const startTime = Date.now();\n const db = createConnection({ client: 'pg', connection });\n\n try {\n for (;;) {\n try {\n const result = await db.select(db.raw('version()'));\n if (Array.isArray(result) && result[0]?.version) {\n return;\n }\n } catch (e) {\n if (Date.now() - startTime > 30_000) {\n throw new Error(\n `Timed out waiting for the database to be ready for connections, ${e}`,\n );\n }\n }\n\n await new Promise(resolve => setTimeout(resolve, 100));\n }\n } finally {\n db.destroy();\n }\n}\n\nexport async function startPostgresContainer(image: string) {\n const user = 'postgres';\n const password = uuid();\n\n // Lazy-load to avoid side-effect of importing testcontainers\n const { GenericContainer } = await import('testcontainers');\n\n const container = await new GenericContainer(image)\n .withExposedPorts(5432)\n .withEnv('POSTGRES_PASSWORD', password)\n .withTmpFs({ '/var/lib/postgresql/data': 'rw' })\n .start();\n\n const host = container.getHost();\n const port = container.getMappedPort(5432);\n const stop = async () => {\n await container.stop({ timeout: 10_000 });\n };\n\n await waitForPostgresReady({ host, port, user, password });\n\n return { host, port, user, password, stop };\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DatabaseManager } from '@backstage/backend-common';\nimport { Knex } from 'knex';\n\n/**\n * The possible databases to test against.\n *\n * @public\n */\nexport type TestDatabaseId =\n | 'POSTGRES_13'\n | 'POSTGRES_9'\n | 'MYSQL_8'\n | 'SQLITE_3';\n\nexport type TestDatabaseProperties = {\n name: string;\n driver: string;\n dockerImageName?: string;\n connectionStringEnvironmentVariableName?: string;\n};\n\nexport type Instance = {\n stopContainer?: () => Promise<void>;\n databaseManager: DatabaseManager;\n connections: Array<Knex>;\n};\n\nexport const allDatabases: Record<TestDatabaseId, TestDatabaseProperties> =\n Object.freeze({\n POSTGRES_13: {\n name: 'Postgres 13.x',\n driver: 'pg',\n dockerImageName: 'postgres:13',\n connectionStringEnvironmentVariableName:\n 'BACKSTAGE_TEST_DATABASE_POSTGRES13_CONNECTION_STRING',\n },\n POSTGRES_9: {\n name: 'Postgres 9.x',\n driver: 'pg',\n dockerImageName: 'postgres:9',\n connectionStringEnvironmentVariableName:\n 'BACKSTAGE_TEST_DATABASE_POSTGRES9_CONNECTION_STRING',\n },\n MYSQL_8: {\n name: 'MySQL 8.x',\n driver: 'mysql2',\n dockerImageName: 'mysql:8',\n connectionStringEnvironmentVariableName:\n 'BACKSTAGE_TEST_DATABASE_MYSQL8_CONNECTION_STRING',\n },\n SQLITE_3: {\n name: 'SQLite 3.x',\n driver: 'better-sqlite3',\n },\n });\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DatabaseManager } from '@backstage/backend-common';\nimport { ConfigReader } from '@backstage/config';\nimport { randomBytes } from 'crypto';\nimport { Knex } from 'knex';\nimport { isDockerDisabledForTests } from '../util/isDockerDisabledForTests';\nimport { startMysqlContainer } from './startMysqlContainer';\nimport { startPostgresContainer } from './startPostgresContainer';\nimport {\n allDatabases,\n Instance,\n TestDatabaseId,\n TestDatabaseProperties,\n} from './types';\n\n/**\n * Encapsulates the creation of ephemeral test database instances for use\n * inside unit or integration tests.\n *\n * @public\n */\nexport class TestDatabases {\n private readonly instanceById: Map<string, Instance>;\n private readonly supportedIds: TestDatabaseId[];\n\n /**\n * Creates an empty `TestDatabases` instance, and sets up Jest to clean up\n * all of its acquired resources after all tests finish.\n *\n * You typically want to create just a single instance like this at the top\n * of your test file or `describe` block, and then call `init` many times on\n * that instance inside the individual tests. Spinning up a \"physical\"\n * database instance takes a considerable amount of time, slowing down tests.\n * But initializing a new logical database inside that instance using `init`\n * is very fast.\n */\n static create(options?: {\n ids?: TestDatabaseId[];\n disableDocker?: boolean;\n }): TestDatabases {\n const defaultOptions = {\n ids: Object.keys(allDatabases) as TestDatabaseId[],\n disableDocker: isDockerDisabledForTests(),\n };\n\n const { ids, disableDocker } = Object.assign(\n {},\n defaultOptions,\n options ?? {},\n );\n\n const supportedIds = ids.filter(id => {\n const properties = allDatabases[id];\n if (!properties) {\n return false;\n }\n // If the caller has set up the env with an explicit connection string,\n // we'll assume that this database will work\n if (\n properties.connectionStringEnvironmentVariableName &&\n process.env[properties.connectionStringEnvironmentVariableName]\n ) {\n return true;\n }\n // If the database doesn't require docker at all, there's nothing to worry\n // about\n if (!properties.dockerImageName) {\n return true;\n }\n // If the database requires docker, but docker is disabled, we will fail.\n if (disableDocker) {\n return false;\n }\n return true;\n });\n\n const databases = new TestDatabases(supportedIds);\n\n if (supportedIds.length > 0) {\n afterAll(async () => {\n await databases.shutdown();\n });\n }\n\n return databases;\n }\n\n private constructor(supportedIds: TestDatabaseId[]) {\n this.instanceById = new Map();\n this.supportedIds = supportedIds;\n }\n\n supports(id: TestDatabaseId): boolean {\n return this.supportedIds.includes(id);\n }\n\n eachSupportedId(): [TestDatabaseId][] {\n return this.supportedIds.map(id => [id]);\n }\n\n /**\n * Returns a fresh, unique, empty logical database on an instance of the\n * given database ID platform.\n *\n * @param id - The ID of the database platform to use, e.g. 'POSTGRES_13'\n * @returns A `Knex` connection object\n */\n async init(id: TestDatabaseId): Promise<Knex> {\n const properties = allDatabases[id];\n if (!properties) {\n const candidates = Object.keys(allDatabases).join(', ');\n throw new Error(\n `Unknown test database ${id}, possible values are ${candidates}`,\n );\n }\n if (!this.supportedIds.includes(id)) {\n const candidates = this.supportedIds.join(', ');\n throw new Error(\n `Unsupported test database ${id} for this environment, possible values are ${candidates}`,\n );\n }\n\n let instance: Instance | undefined = this.instanceById.get(id);\n\n // Ensure that a testcontainers instance is up for this ID\n if (!instance) {\n instance = await this.initAny(properties);\n this.instanceById.set(id, instance);\n }\n\n // Ensure that a unique logical database is created in the instance\n const connection = await instance.databaseManager\n .forPlugin(`db${randomBytes(16).toString('hex')}`)\n .getClient();\n\n instance.connections.push(connection);\n\n return connection;\n }\n\n private async initAny(properties: TestDatabaseProperties): Promise<Instance> {\n // Use the connection string if provided\n if (properties.driver === 'pg' || properties.driver === 'mysql2') {\n const envVarName = properties.connectionStringEnvironmentVariableName;\n if (envVarName) {\n const connectionString = process.env[envVarName];\n if (connectionString) {\n const databaseManager = DatabaseManager.fromConfig(\n new ConfigReader({\n backend: {\n database: {\n client: properties.driver,\n connection: connectionString,\n },\n },\n }),\n );\n return {\n databaseManager,\n connections: [],\n };\n }\n }\n }\n\n // Otherwise start a container for the purpose\n switch (properties.driver) {\n case 'pg':\n return this.initPostgres(properties);\n case 'mysql2':\n return this.initMysql(properties);\n case 'better-sqlite3':\n case 'sqlite3':\n return this.initSqlite(properties);\n default:\n throw new Error(`Unknown database driver ${properties.driver}`);\n }\n }\n\n private async initPostgres(\n properties: TestDatabaseProperties,\n ): Promise<Instance> {\n const { host, port, user, password, stop } = await startPostgresContainer(\n properties.dockerImageName!,\n );\n\n const databaseManager = DatabaseManager.fromConfig(\n new ConfigReader({\n backend: {\n database: {\n client: 'pg',\n connection: { host, port, user, password },\n },\n },\n }),\n );\n\n return {\n stopContainer: stop,\n databaseManager,\n connections: [],\n };\n }\n\n private async initMysql(\n properties: TestDatabaseProperties,\n ): Promise<Instance> {\n const { host, port, user, password, stop } = await startMysqlContainer(\n properties.dockerImageName!,\n );\n\n const databaseManager = DatabaseManager.fromConfig(\n new ConfigReader({\n backend: {\n database: {\n client: 'mysql2',\n connection: { host, port, user, password },\n },\n },\n }),\n );\n\n return {\n stopContainer: stop,\n databaseManager,\n connections: [],\n };\n }\n\n private async initSqlite(\n properties: TestDatabaseProperties,\n ): Promise<Instance> {\n const databaseManager = DatabaseManager.fromConfig(\n new ConfigReader({\n backend: {\n database: {\n client: properties.driver,\n connection: ':memory:',\n },\n },\n }),\n );\n\n return {\n databaseManager,\n connections: [],\n };\n }\n\n private async shutdown() {\n const instances = [...this.instanceById.values()];\n await Promise.all(\n instances.map(async ({ stopContainer, connections }) => {\n try {\n await Promise.all(connections.map(c => c.destroy()));\n } catch {\n // ignore\n }\n try {\n await stopContainer?.();\n } catch {\n // ignore\n }\n }),\n );\n }\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Sets up handlers for request mocking\n * @public\n * @param worker - service worker\n */\nexport function setupRequestMockHandlers(worker: {\n listen: (t: any) => void;\n close: () => void;\n resetHandlers: () => void;\n}) {\n beforeAll(() => worker.listen({ onUnhandledRequest: 'error' }));\n afterAll(() => worker.close());\n afterEach(() => worker.resetHandlers());\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createSpecializedBackend } from '@backstage/backend-app-api';\nimport {\n AnyServiceFactory,\n ServiceRef,\n createServiceFactory,\n BackendFeature,\n ExtensionPoint,\n} from '@backstage/backend-plugin-api';\n\n/** @alpha */\nexport interface TestBackendOptions<\n TServices extends any[],\n TExtensionPoints extends any[],\n> {\n services?: readonly [\n ...{\n [index in keyof TServices]:\n | AnyServiceFactory\n | [ServiceRef<TServices[index]>, Partial<TServices[index]>];\n },\n ];\n extensionPoints?: readonly [\n ...{\n [index in keyof TExtensionPoints]: [\n ExtensionPoint<TExtensionPoints[index]>,\n Partial<TExtensionPoints[index]>,\n ];\n },\n ];\n features?: BackendFeature[];\n}\n\n/** @alpha */\nexport async function startTestBackend<\n TServices extends any[],\n TExtensionPoints extends any[],\n>(options: TestBackendOptions<TServices, TExtensionPoints>): Promise<void> {\n const {\n services = [],\n extensionPoints = [],\n features = [],\n ...otherOptions\n } = options;\n\n const factories = services.map(serviceDef => {\n if (Array.isArray(serviceDef)) {\n // if type is ExtensionPoint?\n // do something differently?\n return createServiceFactory({\n service: serviceDef[0],\n deps: {},\n factory: async () => async () => serviceDef[1],\n });\n }\n return serviceDef as AnyServiceFactory;\n });\n\n const backend = createSpecializedBackend({\n ...otherOptions,\n services: factories,\n });\n\n backend.add({\n id: `---test-extension-point-registrar`,\n register(reg) {\n for (const [ref, impl] of extensionPoints) {\n reg.registerExtensionPoint(ref, impl);\n }\n\n reg.registerInit({ deps: {}, async init() {} });\n },\n });\n\n for (const feature of features) {\n backend.add(feature);\n }\n\n await backend.start();\n}\n"],"names":["createConnection","uuid","randomBytes","DatabaseManager","ConfigReader","createServiceFact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E,IAAI,CAAC,CAAC;AAC9C,OAAO;AACP,MAAM,GAAG,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,IAAI,GAAG;AAChD,OAAO,EAAE,CAAC,CAAC;AACX,KAAK;AACL,GAAG,CAAC,CAAC;AACL,EAAE,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;AAClC,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AACzB,GAAG;AACH,EAAE,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;AACxB;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,14 +1,39 @@
1
+ /**
2
+ * Test helpers library for Backstage backends
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+
7
+ import { AnyServiceFactory } from '@backstage/backend-plugin-api';
8
+ import { BackendFeature } from '@backstage/backend-plugin-api';
9
+ import { ExtensionPoint } from '@backstage/backend-plugin-api';
1
10
  import { Knex } from 'knex';
11
+ import { ServiceRef } from '@backstage/backend-plugin-api';
2
12
 
3
13
  /** @public */
4
- declare function isDockerDisabledForTests(): boolean;
14
+ export declare function isDockerDisabledForTests(): boolean;
15
+
16
+ /**
17
+ * Sets up handlers for request mocking
18
+ * @public
19
+ * @param worker - service worker
20
+ */
21
+ export declare function setupRequestMockHandlers(worker: {
22
+ listen: (t: any) => void;
23
+ close: () => void;
24
+ resetHandlers: () => void;
25
+ }): void;
26
+
27
+ /* Excluded from this release type: startTestBackend */
28
+
29
+ /* Excluded from this release type: TestBackendOptions */
5
30
 
6
31
  /**
7
32
  * The possible databases to test against.
8
33
  *
9
34
  * @public
10
35
  */
11
- declare type TestDatabaseId = 'POSTGRES_13' | 'POSTGRES_9' | 'MYSQL_8' | 'SQLITE_3';
36
+ export declare type TestDatabaseId = 'POSTGRES_13' | 'POSTGRES_9' | 'MYSQL_8' | 'SQLITE_3';
12
37
 
13
38
  /**
14
39
  * Encapsulates the creation of ephemeral test database instances for use
@@ -16,7 +41,7 @@ declare type TestDatabaseId = 'POSTGRES_13' | 'POSTGRES_9' | 'MYSQL_8' | 'SQLITE
16
41
  *
17
42
  * @public
18
43
  */
19
- declare class TestDatabases {
44
+ export declare class TestDatabases {
20
45
  private readonly instanceById;
21
46
  private readonly supportedIds;
22
47
  /**
@@ -52,15 +77,4 @@ declare class TestDatabases {
52
77
  private shutdown;
53
78
  }
54
79
 
55
- /**
56
- * Sets up handlers for request mocking
57
- * @public
58
- * @param worker - service worker
59
- */
60
- declare function setupRequestMockHandlers(worker: {
61
- listen: (t: any) => void;
62
- close: () => void;
63
- resetHandlers: () => void;
64
- }): void;
65
-
66
- export { TestDatabaseId, TestDatabases, isDockerDisabledForTests, setupRequestMockHandlers };
80
+ export { }
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@backstage/backend-test-utils",
3
3
  "description": "Test helpers library for Backstage backends",
4
- "version": "0.1.26-next.3",
4
+ "version": "0.1.27",
5
5
  "main": "dist/index.cjs.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "private": false,
8
8
  "publishConfig": {
9
9
  "access": "public",
10
10
  "main": "dist/index.cjs.js",
11
- "types": "dist/index.d.ts"
11
+ "types": "dist/index.d.ts",
12
+ "alphaTypes": "dist/index.alpha.d.ts"
12
13
  },
13
14
  "backstage": {
14
15
  "role": "node-library"
@@ -25,7 +26,7 @@
25
26
  ],
26
27
  "license": "Apache-2.0",
27
28
  "scripts": {
28
- "build": "backstage-cli package build",
29
+ "build": "backstage-cli package build --experimental-type-build",
29
30
  "lint": "backstage-cli package lint",
30
31
  "test": "backstage-cli package test",
31
32
  "prepack": "backstage-cli package prepack",
@@ -34,22 +35,25 @@
34
35
  "start": "backstage-cli package start"
35
36
  },
36
37
  "dependencies": {
37
- "@backstage/backend-common": "^0.14.1-next.3",
38
- "@backstage/cli": "^0.18.0-next.3",
38
+ "@backstage/backend-app-api": "^0.2.0",
39
+ "@backstage/backend-common": "^0.15.0",
40
+ "@backstage/backend-plugin-api": "^0.1.1",
41
+ "@backstage/cli": "^0.18.1",
39
42
  "@backstage/config": "^1.0.1",
40
43
  "better-sqlite3": "^7.5.0",
41
44
  "knex": "^2.0.0",
42
- "msw": "^0.43.0",
45
+ "msw": "^0.44.0",
43
46
  "mysql2": "^2.2.5",
44
47
  "pg": "^8.3.0",
45
48
  "testcontainers": "^8.1.2",
46
49
  "uuid": "^8.0.0"
47
50
  },
48
51
  "devDependencies": {
49
- "@backstage/cli": "^0.18.0-next.3"
52
+ "@backstage/cli": "^0.18.1"
50
53
  },
51
54
  "files": [
52
- "dist"
55
+ "dist",
56
+ "alpha"
53
57
  ],
54
- "gitHead": "291b3a07233061266d9f3ce431345bf19fa4bbd5"
58
+ "gitHead": "a12f6269e3bf224aa7f52475be9152bc52addeed"
55
59
  }