2021-05-12 06:35:00 +00:00
|
|
|
import { database as db } from '../common/database';
|
2020-07-01 21:17:14 +00:00
|
|
|
import type { BaseModel } from './index';
|
|
|
|
|
|
|
|
export const name = 'Unit Test Result';
|
2021-05-12 06:35:00 +00:00
|
|
|
|
2020-07-01 21:17:14 +00:00
|
|
|
export const type = 'UnitTestResult';
|
2021-05-12 06:35:00 +00:00
|
|
|
|
2020-07-01 21:17:14 +00:00
|
|
|
export const prefix = 'utr';
|
2021-05-12 06:35:00 +00:00
|
|
|
|
2020-07-01 21:17:14 +00:00
|
|
|
export const canDuplicate = false;
|
2021-05-12 06:35:00 +00:00
|
|
|
|
2020-07-01 21:17:14 +00:00
|
|
|
export const canSync = false;
|
|
|
|
|
2021-05-12 06:35:00 +00:00
|
|
|
interface BaseUnitTestResult {
|
|
|
|
results: Record<string, any>;
|
|
|
|
}
|
2020-07-01 21:17:14 +00:00
|
|
|
|
|
|
|
export type UnitTestResult = BaseModel & BaseUnitTestResult;
|
|
|
|
|
2021-06-16 19:19:00 +00:00
|
|
|
export const isUnitTestResult = (model: Pick<BaseModel, 'type'>): model is UnitTestResult => (
|
|
|
|
model.type === type
|
|
|
|
);
|
|
|
|
|
2020-07-01 21:17:14 +00:00
|
|
|
export function init() {
|
|
|
|
return {
|
|
|
|
results: null,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-05-12 06:35:00 +00:00
|
|
|
export function migrate(doc: UnitTestResult) {
|
2020-07-01 21:17:14 +00:00
|
|
|
return doc;
|
|
|
|
}
|
|
|
|
|
2021-05-12 06:35:00 +00:00
|
|
|
export function create(patch: Partial<UnitTestResult> = {}) {
|
2020-07-01 21:17:14 +00:00
|
|
|
if (!patch.parentId) {
|
|
|
|
throw new Error('New UnitTestResult missing `parentId` ' + JSON.stringify(patch));
|
|
|
|
}
|
|
|
|
|
|
|
|
return db.docCreate(type, patch);
|
|
|
|
}
|
|
|
|
|
2021-05-12 06:35:00 +00:00
|
|
|
export function update(unitTest: UnitTestResult, patch: Partial<UnitTestResult>) {
|
2020-07-01 21:17:14 +00:00
|
|
|
return db.docUpdate(unitTest, patch);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getByParentId(parentId: string) {
|
|
|
|
return db.getWhere(type, { parentId });
|
|
|
|
}
|
|
|
|
|
2021-05-12 06:35:00 +00:00
|
|
|
export function all() {
|
|
|
|
return db.all<UnitTestResult>(type);
|
2020-07-01 21:17:14 +00:00
|
|
|
}
|