Skip to content

Commit cc1ecd2

Browse files
committed
copilot review changes
1 parent ae44d23 commit cc1ecd2

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

packages/compass-data-modeling/src/services/data-model-storage-electron.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class DataModelStorageElectron implements DataModelStorage {
1414
constructor(basePath?: string) {
1515
this.userData = new FileUserData(
1616
MongoDBDataModelDescriptionSchema,
17-
'DataModelDescription',
17+
'DataModelDescriptions',
1818
{
1919
basePath,
2020
}

packages/compass-user-data/src/user-data.spec.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ describe('AtlasUserData', function () {
669669
getResourceUrlStub
670670
.onFirstCall()
671671
.resolves(
672-
'cluster-connection.cloud.mongodb.com/FavoriteQueries/test-org/test-proj'
672+
'cluster-connection.cloud.mongodb.com/FavoriteQueries/test-org/test-proj/test-id'
673673
)
674674
.onSecondCall()
675675
.resolves(
@@ -688,7 +688,7 @@ describe('AtlasUserData', function () {
688688

689689
const [getUrl, getOptions] = authenticatedFetchStub.firstCall.args;
690690
expect(getUrl).to.equal(
691-
'cluster-connection.cloud.mongodb.com/FavoriteQueries/test-org/test-proj'
691+
'cluster-connection.cloud.mongodb.com/FavoriteQueries/test-org/test-proj/test-id'
692692
);
693693
expect(getOptions.method).to.equal('GET');
694694

@@ -700,7 +700,7 @@ describe('AtlasUserData', function () {
700700
expect(putOptions.headers['Content-Type']).to.equal('application/json');
701701
});
702702

703-
it('returns false when authenticatedFetch throws an error', async function () {
703+
it('throws error when authenticatedFetch throws an error', async function () {
704704
const getResponse = {
705705
data: JSON.stringify({ name: 'Original Name', hasDarkMode: true }),
706706
};
@@ -714,7 +714,7 @@ describe('AtlasUserData', function () {
714714
getResourceUrlStub
715715
.onFirstCall()
716716
.resolves(
717-
'cluster-connection.cloud.mongodb.com/FavoriteQueries/test-org/test-proj'
717+
'cluster-connection.cloud.mongodb.com/FavoriteQueries/test-org/test-proj/test-id'
718718
)
719719
.onSecondCall()
720720
.resolves(
@@ -723,10 +723,15 @@ describe('AtlasUserData', function () {
723723

724724
const userData = getAtlasUserData();
725725

726-
const result = await userData.updateAttributes('test-id', {
727-
name: 'Updated',
728-
});
729-
expect(result).equals(false);
726+
try {
727+
await userData.updateAttributes('test-id', {
728+
name: 'Updated',
729+
});
730+
expect.fail('Expected method to throw an error');
731+
} catch (error) {
732+
expect(error).to.be.instanceOf(Error);
733+
expect((error as Error).message).to.equal('HTTP 400: Bad Request');
734+
}
730735
});
731736

732737
it('uses custom serializer for request body', async function () {

packages/compass-user-data/src/user-data.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,8 @@ export class FileUserData<T extends z.Schema> extends IUserData<T> {
273273
export class AtlasUserData<T extends z.Schema> extends IUserData<T> {
274274
private readonly authenticatedFetch;
275275
private readonly getResourceUrl;
276-
private orgId: string = '';
277-
private projectId: string = '';
276+
private orgId: string;
277+
private projectId: string;
278278
constructor(
279279
validator: T,
280280
dataType: string,
@@ -420,7 +420,7 @@ export class AtlasUserData<T extends z.Schema> extends IUserData<T> {
420420
error: (error as Error).message,
421421
}
422422
);
423-
return false;
423+
throw error;
424424
}
425425
}
426426

@@ -447,7 +447,7 @@ export class AtlasUserData<T extends z.Schema> extends IUserData<T> {
447447
error: (error as Error).message,
448448
}
449449
);
450-
return null;
450+
throw error;
451451
}
452452
}
453453
}

0 commit comments

Comments
 (0)