Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export class VCoreBranchDataProvider
// Get metadata from cache (may be undefined if not yet loaded)
const cachedMetadata = this.metadataLoader.getCachedMetadata(resource.id);

// Sanitize Azure Resource ID: replace '/' with '-' for both clusterId and treeId
// Sanitize Azure Resource ID: replace '/' with '_' for both clusterId and treeId
const sanitizedId = sanitizeAzureResourceIdForTreeId(resource.id);

let clusterInfo: TreeCluster<AzureClusterModel> = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export class RUBranchDataProvider
// Get metadata from cache (may be undefined if not yet loaded)
const cachedMetadata = this.metadataLoader.getCachedMetadata(resource.id);

// Sanitize Azure Resource ID: replace '/' with '-' for both clusterId and treeId
// Sanitize Azure Resource ID: replace '/' with '_' for both clusterId and treeId
const sanitizedId = sanitizeAzureResourceIdForTreeId(resource.id);

let clusterInfo: TreeCluster<AzureClusterModel> = {
Expand Down
11 changes: 5 additions & 6 deletions src/tree/discovery-view/DiscoveryBranchDataProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ describe('DiscoveryBranchDataProvider - Cluster ID Validation', () => {
expect(children![0].cluster.clusterId).toBe(nonPrefixedClusterId);
});

it('should warn when cluster ID has unexpected provider prefix', async () => {
it('should throw when cluster ID has unexpected provider prefix', async () => {
// Cluster ID with wrong provider prefix
const wrongPrefixClusterId = 'wrong-provider__subscriptions_sub1_clusters_cluster1';
const mockClusterElement = {
Expand All @@ -638,11 +638,10 @@ describe('DiscoveryBranchDataProvider - Cluster ID Validation', () => {
getChildren: jest.fn().mockResolvedValue([mockClusterElement]),
};

const children = await dataProvider.getChildren(mockParentElement);

// Should not throw, but should warn about unexpected prefix
expect(children).toBeDefined();
expect(outputChannelWarnMock).toHaveBeenCalledWith(expect.stringContaining('unexpected prefix'));
// Should throw an error about unexpected prefix
await expect(dataProvider.getChildren(mockParentElement)).rejects.toThrow(
expect.stringMatching(/must start with provider ID.*azure-mongo-vcore-discovery/),
);
});
});
});
4 changes: 2 additions & 2 deletions src/tree/models/BaseClusterModel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ describe('BaseClusterModel', () => {
// The original Azure Resource ID is stored in AzureClusterModel.id
const azureResourceId =
'/subscriptions/sub1/resourceGroups/rg1/providers/Microsoft.DocumentDB/mongoClusters/cluster1';
const sanitizedId = azureResourceId.replace(/\//g, '-');
const sanitizedId = azureResourceId.replace(/\//g, '_');

const cluster: TreeCluster = {
name: 'azure-cluster',
Expand All @@ -124,7 +124,7 @@ describe('BaseClusterModel', () => {
// In Azure Resources View, both clusterId and treeId are sanitized
const azureResourceId =
'/subscriptions/sub1/resourceGroups/rg1/providers/Microsoft.DocumentDB/mongoClusters/cluster1';
const sanitizedId = azureResourceId.replace(/\//g, '-');
const sanitizedId = azureResourceId.replace(/\//g, '_');

const cluster: TreeCluster = {
name: 'azure-cluster',
Expand Down