2021-05-12 06:35:00 +00:00
|
|
|
import { database as db } from '../common/database';
|
|
|
|
import type { BaseModel } from './index';
|
|
|
|
|
|
|
|
export const name = 'Unit Test Suite';
|
|
|
|
|
|
|
|
export const type = 'UnitTestSuite';
|
|
|
|
|
|
|
|
export const prefix = 'uts';
|
|
|
|
|
|
|
|
export const canDuplicate = true;
|
|
|
|
|
|
|
|
export const canSync = true;
|
|
|
|
interface BaseUnitTestSuite {
|
|
|
|
name: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export type UnitTestSuite = BaseModel & BaseUnitTestSuite;
|
|
|
|
|
2021-06-16 19:19:00 +00:00
|
|
|
export const isUnitTestSuite = (model: Pick<BaseModel, 'type'>): model is UnitTestSuite => (
|
|
|
|
model.type === type
|
|
|
|
);
|
|
|
|
|
2021-05-12 06:35:00 +00:00
|
|
|
export function init() {
|
|
|
|
return {
|
|
|
|
name: 'My Test',
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function migrate(doc: UnitTestSuite) {
|
|
|
|
return doc;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function create(patch: Partial<UnitTestSuite> = {}) {
|
|
|
|
if (!patch.parentId) {
|
|
|
|
throw new Error('New UnitTestSuite missing `parentId` ' + JSON.stringify(patch));
|
|
|
|
}
|
|
|
|
|
|
|
|
return db.docCreate<UnitTestSuite>(type, patch);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function update(unitTestSuite: UnitTestSuite, patch: Partial<UnitTestSuite> = {}) {
|
|
|
|
return db.docUpdate<UnitTestSuite>(unitTestSuite, patch);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function remove(unitTestSuite: UnitTestSuite) {
|
|
|
|
return db.remove(unitTestSuite);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getByParentId(parentId: string) {
|
|
|
|
return db.getWhere<UnitTestSuite>(type, { parentId });
|
|
|
|
}
|
|
|
|
|
|
|
|
export function all() {
|
|
|
|
return db.all<UnitTestSuite>(type);
|
|
|
|
}
|