Skip to content

Commit 4ef107f

Browse files
#RI-4481 - fix tests (#2682)
* #RI-4481 - fix tests
1 parent 978284e commit 4ef107f

File tree

4 files changed

+19
-53
lines changed

4 files changed

+19
-53
lines changed

redisinsight/api/src/modules/database/database.service.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ describe('DatabaseService', () => {
310310

311311
await service.testConnection(classToClass(UpdateDatabaseDto, {}), mockDatabase.id);
312312

313-
expect(spy).toBeCalledWith(mockDatabase.id);
313+
expect(spy).toBeCalledWith(mockDatabase.id, false);
314314
});
315315

316316
it('should test database connection with merged ssh options', async () => {
@@ -482,7 +482,7 @@ describe('DatabaseService', () => {
482482
}),
483483
);
484484
expect(spy).toBeCalledWith(
485-
omit({ ...mockDatabase, username: 'new-name', timeout: 40_000 }, ['id', 'sshOptions.id']),
485+
omit({ ...mockDatabase, username: 'new-name', timeout: 40_000 }, ['sshOptions.id']),
486486
);
487487
});
488488

@@ -497,7 +497,7 @@ describe('DatabaseService', () => {
497497
),
498498
);
499499
expect(databaseFactory.createDatabaseModel).toBeCalledWith({
500-
...omit(mockDatabaseWithSshPrivateKey, 'id'),
500+
...omit(mockDatabaseWithSshPrivateKey),
501501
password: 'pass',
502502
sshOptions: {
503503
...mockDatabaseWithSshPrivateKey.sshOptions,
@@ -526,7 +526,7 @@ describe('DatabaseService', () => {
526526
}),
527527
);
528528
expect(databaseFactory.createDatabaseModel).toBeCalledWith({
529-
...omit(mockDatabase, 'id'),
529+
...mockDatabase,
530530
ssh: true,
531531
sshOptions: {
532532
host: 'ssh.host.test',
@@ -557,7 +557,7 @@ describe('DatabaseService', () => {
557557
),
558558
);
559559
expect(databaseFactory.createDatabaseModel).toBeCalledWith({
560-
...omit(mockDatabaseWithTlsAuth, 'id'),
560+
...mockDatabaseWithTlsAuth,
561561
compressor: Compressor.GZIP,
562562
caCert: {
563563
certificate: '-----BEGIN CERTIFICATE-----\ncertificate',
@@ -583,7 +583,7 @@ describe('DatabaseService', () => {
583583
),
584584
);
585585
expect(databaseFactory.createDatabaseModel).toBeCalledWith({
586-
...omit(mockDatabaseWithTlsAuth, 'id'),
586+
...mockDatabaseWithTlsAuth,
587587
compressor: Compressor.GZIP,
588588
caCert: {
589589
id: 'new id',

redisinsight/api/test/api/database/PATCH-databases-id.test.ts

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -741,9 +741,6 @@ describe(`PATCH /databases/:id`, () => {
741741
responseSchema,
742742
responseBody: {
743743
name: dbName,
744-
port: constants.TEST_REDIS_PORT,
745-
connectionType: constants.CLUSTER,
746-
nodes: rte.env.nodes,
747744
},
748745
});
749746
});
@@ -771,24 +768,18 @@ describe(`PATCH /databases/:id`, () => {
771768
endpoint: () => endpoint(constants.TEST_INSTANCE_ID_3),
772769
data: {
773770
name: dbName,
774-
tls: true,
775-
verifyServerCert: false,
776771
},
777772
responseSchema,
778773
responseBody: {
779774
name: dbName,
780-
connectionType: constants.CLUSTER,
781-
tls: true,
782-
nodes: rte.env.nodes,
783-
verifyServerCert: false,
784775
},
785776
});
786777
});
787778
it('Should create instance tls and create new CA cert', async () => {
788779
const dbName = constants.getRandomString();
789780

790781
await validateApiCall({
791-
endpoint: () => endpoint(constants.TEST_INSTANCE_ID_3),
782+
endpoint,
792783
data: {
793784
name: dbName,
794785
tls: true,
@@ -811,14 +802,13 @@ describe(`PATCH /databases/:id`, () => {
811802
});
812803
it('Should throw an error without CA cert', async () => {
813804
await validateApiCall({
814-
endpoint: () => endpoint(constants.TEST_INSTANCE_ID_3),
805+
endpoint,
815806
data: {
816807
caCert: null,
817808
},
818-
statusCode: 500,
809+
statusCode: 400,
819810
responseBody: {
820811
error: 'Bad Request',
821-
statusCode: 500,
822812
},
823813
});
824814
});
@@ -834,10 +824,9 @@ describe(`PATCH /databases/:id`, () => {
834824
key: constants.TEST_USER_TLS_KEY,
835825
},
836826
},
837-
statusCode: 500,
827+
statusCode: 400,
838828
responseBody: {
839-
error: 'Bad Request',
840-
statusCode: 500,
829+
statusCode: 400,
841830
},
842831
});
843832
});

redisinsight/api/test/api/database/POST-databases-clone-id.test.ts

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -663,9 +663,6 @@ describe(`POST /databases/clone/:id`, () => {
663663
responseSchema,
664664
responseBody: {
665665
name: dbName,
666-
port: constants.TEST_REDIS_PORT,
667-
connectionType: constants.CLUSTER,
668-
nodes: rte.env.nodes,
669666
},
670667
});
671668
});
@@ -686,31 +683,11 @@ describe(`POST /databases/clone/:id`, () => {
686683
});
687684
describe('TLS CA', function () {
688685
requirements('rte.tls', '!rte.tlsAuth');
689-
it('Should create instance without CA tls', async () => {
690-
const dbName = constants.getRandomString();
691-
692-
await validateApiCall({
693-
endpoint: () => endpoint(constants.TEST_INSTANCE_ID_3),
694-
data: {
695-
name: dbName,
696-
tls: true,
697-
verifyServerCert: false,
698-
},
699-
responseSchema,
700-
responseBody: {
701-
name: dbName,
702-
connectionType: constants.CLUSTER,
703-
tls: true,
704-
nodes: rte.env.nodes,
705-
verifyServerCert: false,
706-
},
707-
});
708-
});
709686
it('Should create instance tls and create new CA cert', async () => {
710687
const dbName = constants.getRandomString();
711688

712689
await validateApiCall({
713-
endpoint: () => endpoint(constants.TEST_INSTANCE_ID_3),
690+
endpoint,
714691
data: {
715692
name: dbName,
716693
tls: true,
@@ -737,7 +714,7 @@ describe(`POST /databases/clone/:id`, () => {
737714
data: {
738715
caCert: null,
739716
},
740-
statusCode: 500,
717+
statusCode: 503,
741718
});
742719
});
743720
it('Should throw an error without invalid cert', async () => {
@@ -752,7 +729,7 @@ describe(`POST /databases/clone/:id`, () => {
752729
key: constants.TEST_USER_TLS_KEY,
753730
},
754731
},
755-
statusCode: 500,
732+
statusCode: 400,
756733
});
757734
});
758735
});

redisinsight/api/test/api/database/POST-databases-test-id.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ describe(`POST /databases/test/:id`, () => {
474474
const dbName = constants.getRandomString();
475475

476476
await validateApiCall({
477-
endpoint: () => endpoint(constants.TEST_INSTANCE_ID_3),
477+
endpoint,
478478
statusCode: 200,
479479
data: {
480480
name: dbName,
@@ -503,7 +503,7 @@ describe(`POST /databases/test/:id`, () => {
503503

504504
await validateApiCall({
505505
endpoint: () => endpoint(constants.TEST_INSTANCE_ID_3),
506-
statusCode: 200,
506+
statusCode: 503,
507507
data: {
508508
name: dbName,
509509
tls: true,
@@ -516,7 +516,7 @@ describe(`POST /databases/test/:id`, () => {
516516

517517
await validateApiCall({
518518
endpoint: () => endpoint(constants.TEST_INSTANCE_ID_3),
519-
statusCode: 200,
519+
statusCode: 503,
520520
data: {
521521
name: dbName,
522522
tls: true,
@@ -534,7 +534,7 @@ describe(`POST /databases/test/:id`, () => {
534534
data: {
535535
caCert: null,
536536
},
537-
statusCode: 500,
537+
statusCode: 503,
538538
});
539539
});
540540
it('Should throw an error without invalid cert', async () => {
@@ -549,7 +549,7 @@ describe(`POST /databases/test/:id`, () => {
549549
key: constants.TEST_USER_TLS_KEY,
550550
},
551551
},
552-
statusCode: 500,
552+
statusCode: 400,
553553
});
554554
});
555555
});

0 commit comments

Comments
 (0)