fix tsc issues

Signed-off-by: Kiss Miklos <miklos@roadie.io>
This commit is contained in:
Kiss Miklos
2022-07-01 12:17:53 +02:00
parent 2355a43259
commit 2eb8c3d71b
6 changed files with 11 additions and 62 deletions
@@ -24,7 +24,6 @@ import { DateTime } from 'luxon';
import { applyDatabaseMigrations } from './migrations';
import { DefaultProcessingDatabase } from './DefaultProcessingDatabase';
import {
DbRefreshKeysRow,
DbRefreshStateReferencesRow,
DbRefreshStateRow,
DbRelationsRow,
@@ -68,10 +67,6 @@ describe('Default Processing Database', () => {
await db<DbRefreshStateRow>('refresh_state').insert(ref);
};
const insertRefreshKeysRow = async (db: Knex, ref: DbRefreshKeysRow) => {
await db('refresh_keys').insert(ref);
};
describe('updateProcessedEntity', () => {
let id: string;
let processedEntity: Entity;
@@ -103,6 +98,7 @@ describe('Default Processing Database', () => {
resultHash: '',
relations: [],
deferredEntities: [],
refreshKeys: [],
}),
).rejects.toThrow(
`Conflicting write of processing result for ${id} with location key 'undefined'`,
@@ -122,6 +118,7 @@ describe('Default Processing Database', () => {
relations: [],
deferredEntities: [],
locationKey: 'key',
refreshKeys: [],
errors: "['something broke']",
};
const { knex, db } = await createDatabase(databaseId);
@@ -148,6 +145,7 @@ describe('Default Processing Database', () => {
...options,
resultHash: '',
locationKey: 'fail',
refreshKeys: [],
}),
).rejects.toThrow(
`Conflicting write of processing result for ${id} with location key 'fail'`,
@@ -179,6 +177,7 @@ describe('Default Processing Database', () => {
relations: [],
deferredEntities: [],
locationKey: 'key',
refreshKeys: [],
errors: "['something broke']",
}),
);
@@ -233,6 +232,7 @@ describe('Default Processing Database', () => {
resultHash: '',
relations: relations,
deferredEntities: [],
refreshKeys: [],
}),
);
@@ -255,6 +255,7 @@ describe('Default Processing Database', () => {
resultHash: '',
relations: relations,
deferredEntities: [],
refreshKeys: [],
}),
);
@@ -314,6 +315,7 @@ describe('Default Processing Database', () => {
resultHash: '',
relations: [],
deferredEntities,
refreshKeys: [],
}),
);
@@ -405,6 +407,7 @@ describe('Default Processing Database', () => {
processedEntity,
resultHash: '',
relations: [],
refreshKeys: [],
deferredEntities: [
{
entity: {
@@ -1402,55 +1405,4 @@ describe('Default Processing Database', () => {
},
);
});
describe('setRefreshKeys', () => {
it.each(databases.eachSupportedId())(
'should set keys, %p',
async databaseId => {
const { knex, db } = await createDatabase(databaseId);
await db.transaction(async tx =>
db.setRefreshKeys(tx, {
refreshKeys: [{ entityRef: 'location:default/root-1', key: 'foo' }],
}),
);
const rows = await knex<DbRefreshKeysRow>('refresh_keys').select();
expect(rows.length).toBe(1);
expect(rows[0]).toEqual({
entity_ref: 'location:default/root-1',
key: 'foo',
});
},
);
});
describe('deleteRefreshKeys', () => {
it.each(databases.eachSupportedId())(
'should delete keys, %p',
async databaseId => {
const { knex, db } = await createDatabase(databaseId);
await insertRefreshKeysRow(knex, {
entity_ref: 'location:default/root-1',
key: 'foo',
});
let rows = await knex<DbRefreshKeysRow>('refresh_keys').select();
expect(rows.length).toBe(1);
await db.transaction(async tx =>
db.deleteRefreshKey(tx, {
key: 'foo',
}),
);
rows = await knex<DbRefreshKeysRow>('refresh_keys').select();
expect(rows.length).toBe(0);
},
);
});
});
@@ -33,7 +33,6 @@ import {
UpdateEntityCacheOptions,
ListParentsOptions,
ListParentsResult,
RefreshKeyOptions,
RefreshByKeyOptions,
} from './types';
import { DeferredEntity } from '../processing/types';
@@ -25,7 +25,6 @@ import {
LocationSpec,
processingResult,
} from '../../api';
import { stringifyEntityRef } from '@backstage/catalog-model';
const glob = promisify(g);
@@ -15,7 +15,7 @@
*/
import { UrlReader } from '@backstage/backend-common';
import { Entity, stringifyEntityRef } from '@backstage/catalog-model';
import { Entity } from '@backstage/catalog-model';
import { JsonValue } from '@backstage/types';
import { ScmIntegrationRegistry } from '@backstage/integration';
import yaml from 'yaml';
@@ -15,7 +15,7 @@
*/
import { UrlReader } from '@backstage/backend-common';
import { Entity, stringifyEntityRef } from '@backstage/catalog-model';
import { Entity } from '@backstage/catalog-model';
import { assertError } from '@backstage/errors';
import parseGitUrl from 'git-url-parse';
import limiterFactory from 'p-limit';
@@ -30,7 +30,6 @@ import {
LocationSpec,
processingResult,
} from '../../api';
import { locationSpecToLocationEntity } from '../../util';
const CACHE_KEY = 'v1';
@@ -119,7 +119,7 @@ export class ProcessorOutputCollector {
} else if (i.type === 'error') {
this.errors.push(i.error);
} else if (i.type === 'refresh') {
this.refreshKeys.push({ key: i.key, entityRef: i.entityRef });
this.refreshKeys.push({ key: i.key });
}
}
}