mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-15 00:54:06 -08:00
wip: rename entity to TestDefinition
This commit is contained in:
parent
ebfd89d519
commit
3c8be2d589
|
@ -1,61 +0,0 @@
|
||||||
import {
|
|
||||||
Column,
|
|
||||||
Entity,
|
|
||||||
Generated,
|
|
||||||
Index,
|
|
||||||
ManyToOne,
|
|
||||||
OneToOne,
|
|
||||||
PrimaryColumn,
|
|
||||||
RelationId,
|
|
||||||
} from '@n8n/typeorm';
|
|
||||||
import { Length } from 'class-validator';
|
|
||||||
|
|
||||||
import { AnnotationTagEntity } from '@/databases/entities/annotation-tag-entity.ee';
|
|
||||||
import { WorkflowEntity } from '@/databases/entities/workflow-entity';
|
|
||||||
|
|
||||||
import { WithTimestamps } from './abstract-entity';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Entity representing a Test
|
|
||||||
* It combines:
|
|
||||||
* - the workflow under test
|
|
||||||
* - the workflow used to evaluate the results of test execution
|
|
||||||
* - the filter used to select test cases from previous executions of the workflow under test - annotation tag
|
|
||||||
*/
|
|
||||||
@Entity()
|
|
||||||
@Index(['workflow'])
|
|
||||||
@Index(['evaluationWorkflow'])
|
|
||||||
export class TestEntity extends WithTimestamps {
|
|
||||||
@Generated()
|
|
||||||
@PrimaryColumn()
|
|
||||||
id: number;
|
|
||||||
|
|
||||||
@Column({ length: 255 })
|
|
||||||
@Length(1, 255, { message: 'Test name must be $constraint1 to $constraint2 characters long.' })
|
|
||||||
name: string;
|
|
||||||
|
|
||||||
@RelationId((test: TestEntity) => test.workflow)
|
|
||||||
workflowId: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Relation to the workflow under test
|
|
||||||
*/
|
|
||||||
@ManyToOne('WorkflowEntity', 'tests')
|
|
||||||
workflow: WorkflowEntity;
|
|
||||||
|
|
||||||
@RelationId((test: TestEntity) => test.evaluationWorkflow)
|
|
||||||
evaluationWorkflowId: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Relation to the workflow used to evaluate the results of test execution
|
|
||||||
*/
|
|
||||||
@ManyToOne('WorkflowEntity', 'evaluationTests')
|
|
||||||
evaluationWorkflow: WorkflowEntity;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Relation to the annotation tag associated with the test
|
|
||||||
* This tag will be used to select the test cases to run from previous executions
|
|
||||||
*/
|
|
||||||
@OneToOne('AnnotationTagEntity', 'test')
|
|
||||||
annotationTag: AnnotationTagEntity;
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
|
||||||
|
|
||||||
const testEntityTableName = 'test_entity';
|
|
||||||
|
|
||||||
export class CreateTestEntityTable1730386903556 implements ReversibleMigration {
|
|
||||||
async up({ schemaBuilder: { createTable, column } }: MigrationContext) {
|
|
||||||
await createTable(testEntityTableName)
|
|
||||||
.withColumns(
|
|
||||||
column('id').int.notNull.primary.autoGenerate,
|
|
||||||
column('name').varchar(255).notNull,
|
|
||||||
column('workflowId').varchar(36).notNull,
|
|
||||||
column('evaluationWorkflowId').varchar(36),
|
|
||||||
column('annotationTagId').varchar(16),
|
|
||||||
)
|
|
||||||
.withIndexOn('workflowId')
|
|
||||||
.withIndexOn('evaluationWorkflowId')
|
|
||||||
.withForeignKey('workflowId', {
|
|
||||||
tableName: 'workflow_entity',
|
|
||||||
columnName: 'id',
|
|
||||||
onDelete: 'CASCADE',
|
|
||||||
})
|
|
||||||
.withForeignKey('evaluationWorkflowId', {
|
|
||||||
tableName: 'workflow_entity',
|
|
||||||
columnName: 'id',
|
|
||||||
})
|
|
||||||
.withForeignKey('annotationTagId', {
|
|
||||||
tableName: 'annotation_tag_entity',
|
|
||||||
columnName: 'id',
|
|
||||||
}).withTimestamps;
|
|
||||||
}
|
|
||||||
|
|
||||||
async down({ schemaBuilder: { dropTable } }: MigrationContext) {
|
|
||||||
await dropTable(testEntityTableName);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue