diff --git a/plugins/catalog-backend/src/providers/DefaultLocationStore.test.ts b/plugins/catalog-backend/src/providers/DefaultLocationStore.test.ts index 2f68723f37..b11687e33f 100644 --- a/plugins/catalog-backend/src/providers/DefaultLocationStore.test.ts +++ b/plugins/catalog-backend/src/providers/DefaultLocationStore.test.ts @@ -154,10 +154,8 @@ describe('DefaultLocationStore', () => { type: 'url', }, }), - locationKey: computeLocationEntityRef( - 'url', - 'https://github.com/backstage/demo/blob/master/catalog-info.yml', - ), + locationKey: + 'url:https://github.com/backstage/demo/blob/master/catalog-info.yml', }, ]), }); @@ -265,10 +263,8 @@ describe('DefaultLocationStore', () => { type: 'url', }, }), - locationKey: computeLocationEntityRef( - 'url', - 'https://github.com/backstage/demo/blob/master/catalog-info.yml', - ), + locationKey: + 'url:https://github.com/backstage/demo/blob/master/catalog-info.yml', }, ], }); @@ -345,9 +341,7 @@ describe('DefaultLocationStore', () => { entity: expect.objectContaining({ spec: { type: 'url', target: 'https://example.com/new' }, }), - // locationKey is the stable entityRef from when the location was - // originally created, not derived from the new type:target - locationKey: created.entityRef, + locationKey: 'url:https://example.com/new', }, ], }); @@ -473,7 +467,7 @@ describe('DefaultLocationStore', () => { type: 'url', }, }), - locationKey: computeLocationEntityRef('url', matchTarget), + locationKey: `url:${matchTarget}`, }, ], removed: [], @@ -488,7 +482,7 @@ describe('DefaultLocationStore', () => { type: 'url', }, }), - locationKey: computeLocationEntityRef('url', otherTarget), + locationKey: `url:${otherTarget}`, }, ], removed: [], @@ -590,7 +584,7 @@ describe('DefaultLocationStore', () => { type: 'url', }, }), - locationKey: computeLocationEntityRef('url', matchTarget), + locationKey: `url:${matchTarget}`, }, ], removed: [], @@ -605,7 +599,7 @@ describe('DefaultLocationStore', () => { type: 'url', }, }), - locationKey: computeLocationEntityRef('url', otherTarget), + locationKey: `url:${otherTarget}`, }, ], removed: [], @@ -657,10 +651,7 @@ describe('DefaultLocationStore', () => { type: 'url', }, }), - locationKey: computeLocationEntityRef( - 'url', - 'https://github.com/backstage/freben/blob/master/catalog-info.yaml', - ), + locationKey: `url:https://github.com/backstage/freben/blob/master/catalog-info.yaml`, }, ], removed: [], @@ -732,7 +723,7 @@ describe('DefaultLocationStore', () => { type: 'url', }, }), - locationKey: computeLocationEntityRef('url', matchTarget), + locationKey: `url:${matchTarget}`, }, ], removed: [], @@ -747,7 +738,7 @@ describe('DefaultLocationStore', () => { type: 'url', }, }), - locationKey: computeLocationEntityRef('url', otherTarget), + locationKey: `url:${otherTarget}`, }, ], removed: [], @@ -849,7 +840,7 @@ describe('DefaultLocationStore', () => { type: 'url', }, }), - locationKey: computeLocationEntityRef('url', matchTarget), + locationKey: `url:${matchTarget}`, }, ], removed: [], @@ -864,7 +855,7 @@ describe('DefaultLocationStore', () => { type: 'url', }, }), - locationKey: computeLocationEntityRef('url', otherTarget), + locationKey: `url:${otherTarget}`, }, ], removed: [], @@ -915,10 +906,7 @@ describe('DefaultLocationStore', () => { type: 'url', }, }), - locationKey: computeLocationEntityRef( - 'url', - 'https://github.com/freben/demo-renamed/blob/master/folder/catalog-info.yaml', - ), + locationKey: `url:https://github.com/freben/demo-renamed/blob/master/folder/catalog-info.yaml`, }, ], removed: [], diff --git a/plugins/catalog-backend/src/providers/DefaultLocationStore.ts b/plugins/catalog-backend/src/providers/DefaultLocationStore.ts index 9e8d0341d1..519835439f 100644 --- a/plugins/catalog-backend/src/providers/DefaultLocationStore.ts +++ b/plugins/catalog-backend/src/providers/DefaultLocationStore.ts @@ -23,6 +23,7 @@ import { DbRefreshStateRow, DbSearchRow, } from '../database/tables'; +import { getEntityLocationRef } from '../processing/util'; import { EntityProvider, EntityProviderConnection, @@ -116,7 +117,7 @@ export class DefaultLocationStore implements LocationStore, EntityProvider { }); await this.connection.applyMutation({ type: 'delta', - added: [{ entity, locationKey: location.location_entity_ref }], + added: [{ entity, locationKey: getEntityLocationRef(entity) }], removed: [], }); @@ -266,7 +267,7 @@ export class DefaultLocationStore implements LocationStore, EntityProvider { await this.connection.applyMutation({ type: 'delta', - added: [{ entity, locationKey: row.location_entity_ref }], + added: [{ entity, locationKey: getEntityLocationRef(entity) }], removed: [], }); @@ -302,7 +303,7 @@ export class DefaultLocationStore implements LocationStore, EntityProvider { await this.connection.applyMutation({ type: 'delta', added: [], - removed: [{ entity, locationKey: deleted.location_entity_ref }], + removed: [{ entity, locationKey: getEntityLocationRef(entity) }], }); } @@ -368,7 +369,7 @@ export class DefaultLocationStore implements LocationStore, EntityProvider { location, locationEntityRef: location.location_entity_ref, }); - return { entity, locationKey: location.location_entity_ref }; + return { entity, locationKey: getEntityLocationRef(entity) }; }); await this.connection.applyMutation({ @@ -499,7 +500,7 @@ export class DefaultLocationStore implements LocationStore, EntityProvider { location, locationEntityRef: location.location_entity_ref, }); - return { entity, locationKey: location.location_entity_ref }; + return { entity, locationKey: getEntityLocationRef(entity) }; }), removed: [], });