Skip to content

Commit e75ddeb

Browse files
committed
fix tests
1 parent 481bed9 commit e75ddeb

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

src/platform/notebooks/deepnote/integrationStorage.unit.test.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { assert } from 'chai';
1+
import assert from 'assert';
22
import { anything, instance, mock, when } from 'ts-mockito';
33

44
import { IEncryptedStorage } from '../../common/application/types';
@@ -217,7 +217,7 @@ suite('IntegrationStorage', () => {
217217
assert.strictEqual(result, undefined);
218218
});
219219

220-
test('Fires onDidChangeIntegrations event when saving', (done) => {
220+
test('Fires onDidChangeIntegrations event when saving', async () => {
221221
const config: DatabaseIntegrationConfig = {
222222
id: 'postgres-1',
223223
name: 'My Postgres',
@@ -232,11 +232,13 @@ suite('IntegrationStorage', () => {
232232
}
233233
};
234234

235+
let eventCount = 0;
235236
storage.onDidChangeIntegrations(() => {
236-
done();
237+
eventCount++;
237238
});
238239

239-
storage.save(config);
240+
await storage.save(config);
241+
assert.strictEqual(eventCount, 1);
240242
});
241243
});
242244

@@ -263,7 +265,7 @@ suite('IntegrationStorage', () => {
263265
assert.strictEqual(result, undefined);
264266
});
265267

266-
test('Fires onDidChangeIntegrations event when deleting', (done) => {
268+
test('Fires onDidChangeIntegrations event when deleting', async () => {
267269
const config: DatabaseIntegrationConfig = {
268270
id: 'postgres-1',
269271
name: 'My Postgres',
@@ -281,13 +283,10 @@ suite('IntegrationStorage', () => {
281283
let eventCount = 0;
282284
storage.onDidChangeIntegrations(() => {
283285
eventCount++;
284-
if (eventCount === 2) {
285-
// First event is from save, second is from delete
286-
done();
287-
}
288286
});
289287

290-
storage.save(config).then(() => storage.delete('postgres-1'));
288+
await storage.save(config).then(() => storage.delete('postgres-1'));
289+
assert.strictEqual(eventCount, 2);
291290
});
292291
});
293292

@@ -352,12 +351,14 @@ suite('IntegrationStorage', () => {
352351
assert.deepStrictEqual(result, []);
353352
});
354353

355-
test('Fires onDidChangeIntegrations event when clearing', (done) => {
354+
test('Fires onDidChangeIntegrations event when clearing', async () => {
355+
let eventCount = 0;
356356
storage.onDidChangeIntegrations(() => {
357-
done();
357+
eventCount++;
358358
});
359359

360-
storage.clear();
360+
await storage.clear();
361+
assert.strictEqual(eventCount, 1);
361362
});
362363
});
363364

src/platform/notebooks/deepnote/legacyIntegrationConfigUtils.unit.test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { assert } from 'chai';
1+
import assert from 'assert';
22

33
import { upgradeLegacyIntegrationConfig } from './legacyIntegrationConfigUtils';
44
import {
@@ -54,6 +54,7 @@ suite('upgradeLegacyIntegrationConfig', () => {
5454
const result = await upgradeLegacyIntegrationConfig(legacyConfig);
5555

5656
assert.ok(result);
57+
assert.strictEqual(result.type, 'pgsql');
5758
assert.strictEqual(result.metadata.sslEnabled, false);
5859
});
5960

@@ -72,6 +73,7 @@ suite('upgradeLegacyIntegrationConfig', () => {
7273
const result = await upgradeLegacyIntegrationConfig(legacyConfig);
7374

7475
assert.ok(result);
76+
assert.strictEqual(result.type, 'pgsql');
7577
assert.strictEqual(result.metadata.port, '5433');
7678
assert.strictEqual(typeof result.metadata.port, 'string');
7779
});
@@ -161,7 +163,7 @@ suite('upgradeLegacyIntegrationConfig', () => {
161163
assert.strictEqual(result.name, 'My Snowflake');
162164
assert.strictEqual(result.type, 'snowflake');
163165
// The authMethod is converted to the database-integrations format (lowercase/kebab-case)
164-
assert.ok(result.metadata.authMethod);
166+
assert.strictEqual(result.metadata.authMethod, 'password');
165167
assert.strictEqual(result.metadata.accountName, 'myaccount');
166168
assert.strictEqual(result.metadata.warehouse, 'mywarehouse');
167169
assert.strictEqual(result.metadata.database, 'mydb');
@@ -184,7 +186,8 @@ suite('upgradeLegacyIntegrationConfig', () => {
184186
const result = await upgradeLegacyIntegrationConfig(legacyConfig);
185187

186188
assert.ok(result);
187-
assert.ok(result.metadata.authMethod);
189+
assert.strictEqual(result.type, 'snowflake');
190+
assert.strictEqual(result.metadata.authMethod, 'password');
188191
assert.strictEqual(result.metadata.accountName, 'myaccount');
189192
assert.strictEqual(result.metadata.username, 'myuser');
190193
assert.strictEqual(result.metadata.password, 'mypass');
@@ -228,7 +231,7 @@ suite('upgradeLegacyIntegrationConfig', () => {
228231
assert.strictEqual(result.id, 'snowflake-keypair-1');
229232
assert.strictEqual(result.name, 'My Snowflake KeyPair');
230233
assert.strictEqual(result.type, 'snowflake');
231-
assert.ok(result.metadata.authMethod);
234+
assert.strictEqual(result.metadata.authMethod, 'service-account-key-pair');
232235
assert.strictEqual(result.metadata.accountName, 'myaccount');
233236
assert.strictEqual(result.metadata.username, 'myuser');
234237
assert.strictEqual(
@@ -252,6 +255,7 @@ suite('upgradeLegacyIntegrationConfig', () => {
252255
const result = await upgradeLegacyIntegrationConfig(legacyConfig);
253256

254257
assert.ok(result);
258+
assert.strictEqual(result.type, 'snowflake');
255259
assert.ok(result.metadata.authMethod);
256260
});
257261

0 commit comments

Comments
 (0)