Skip to content

Commit fa78f52

Browse files
committed
m
1 parent 301919a commit fa78f52

File tree

4 files changed

+26
-11
lines changed

4 files changed

+26
-11
lines changed

workspaces/x2a/plugins/x2a-backend/src/router.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { X2ADatabaseService } from './services/X2ADatabaseService';
2929
import { ProjectsPostRequest } from '@red-hat-developer-hub/backstage-plugin-x2a-common';
3030
import { migrate } from './services/dbMigrate';
3131
import { Knex } from 'knex';
32+
import { nonExistentId } from './utils';
3233

3334
const databases = TestDatabases.create({
3435
ids: ['SQLITE_3', 'POSTGRES_18'],
@@ -240,7 +241,6 @@ describe('createRouter', () => {
240241
const { client } = await createDatabase(databaseId);
241242
const app = await createApp(client);
242243

243-
const nonExistentId = '00000000-0000-0000-0000-000000000000';
244244
const response = await request(app)
245245
.get(`/projects/${nonExistentId}`)
246246
.send();
@@ -294,7 +294,6 @@ describe('createRouter', () => {
294294
const { client } = await createDatabase(databaseId);
295295
const app = await createApp(client);
296296

297-
const nonExistentId = '00000000-0000-0000-0000-000000000000';
298297
const response = await request(app)
299298
.delete(`/projects/${nonExistentId}`)
300299
.send();
@@ -469,7 +468,6 @@ describe('createRouter', () => {
469468
AuthorizeResult.ALLOW,
470469
);
471470

472-
const nonExistentId = '00000000-0000-0000-0000-000000000000';
473471
const response = await request(app)
474472
.delete(`/projects/${nonExistentId}`)
475473
.send();

workspaces/x2a/plugins/x2a-backend/src/services/X2ADatabaseService.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
import { Knex } from 'knex';
2424
import { X2ADatabaseService } from './X2ADatabaseService';
2525
import { migrate } from './dbMigrate';
26-
import { delay, toSorted } from '../utils';
26+
import { delay, nonExistentId, toSorted } from '../utils';
2727

2828
const databases = TestDatabases.create({
2929
ids: ['SQLITE_3', 'POSTGRES_18'],
@@ -639,7 +639,7 @@ describe('X2ADatabaseService', () => {
639639
const credentials = mockCredentials.user();
640640
const project = await service.getProject(
641641
{
642-
projectId: 'non-existent-id',
642+
projectId: nonExistentId,
643643
},
644644
{ credentials },
645645
);
@@ -860,7 +860,7 @@ describe('X2ADatabaseService', () => {
860860
const credentials = mockCredentials.user();
861861
const deletedCount = await service.deleteProject(
862862
{
863-
projectId: 'non-existent-id',
863+
projectId: nonExistentId,
864864
},
865865
{ credentials },
866866
);
@@ -1307,7 +1307,7 @@ describe('X2ADatabaseService', () => {
13071307
const { client } = await createDatabase(databaseId);
13081308
const service = createService(client);
13091309

1310-
const module = await service.getModule({ id: 'non-existent-id' });
1310+
const module = await service.getModule({ id: nonExistentId });
13111311

13121312
expect(module).toBeUndefined();
13131313
},
@@ -1515,7 +1515,7 @@ describe('X2ADatabaseService', () => {
15151515
const service = createService(client);
15161516

15171517
const deletedCount = await service.deleteModule({
1518-
id: 'non-existent-id',
1518+
id: nonExistentId,
15191519
});
15201520

15211521
expect(deletedCount).toBe(0);
@@ -2002,7 +2002,7 @@ describe('X2ADatabaseService', () => {
20022002
const { client } = await createDatabase(databaseId);
20032003
const service = createService(client);
20042004

2005-
const job = await service.getJob({ id: 'non-existent-id' });
2005+
const job = await service.getJob({ id: nonExistentId });
20062006

20072007
expect(job).toBeUndefined();
20082008
},
@@ -2296,7 +2296,7 @@ describe('X2ADatabaseService', () => {
22962296
const service = createService(client);
22972297

22982298
const updated = await service.updateJob({
2299-
id: 'non-existent-id',
2299+
id: nonExistentId,
23002300
status: 'running',
23012301
});
23022302

@@ -2563,7 +2563,7 @@ describe('X2ADatabaseService', () => {
25632563
const service = createService(client);
25642564

25652565
const deletedCount = await service.deleteJob({
2566-
id: 'non-existent-id',
2566+
id: nonExistentId,
25672567
});
25682568

25692569
expect(deletedCount).toBe(0);

workspaces/x2a/plugins/x2a-backend/src/utils/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515
*/
1616
export * from './toSorted';
1717
export * from './delay';
18+
export * from './tests';
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright Red Hat, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
export const nonExistentId = '00000000-0000-0000-0000-000000000000';

0 commit comments

Comments
 (0)