mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-02 07:01:30 -08:00
wip: rename Test to TestDefinition
This commit is contained in:
parent
a099769d4c
commit
f61653f2e2
|
@ -6,7 +6,7 @@ import { TestDefinition } from '@/databases/entities/test-definition';
|
|||
import type { ListQuery } from '@/requests';
|
||||
|
||||
@Service()
|
||||
export class TestRepository extends Repository<TestDefinition> {
|
||||
export class TestDefinitionRepository extends Repository<TestDefinition> {
|
||||
constructor(dataSource: DataSource) {
|
||||
super(TestDefinition, dataSource.manager);
|
||||
}
|
||||
|
@ -32,9 +32,9 @@ export class TestRepository extends Repository<TestDefinition> {
|
|||
findManyOptions.take = options.take;
|
||||
}
|
||||
|
||||
const [tests, count] = await this.findAndCount(findManyOptions);
|
||||
const [testDefinitions, count] = await this.findAndCount(findManyOptions);
|
||||
|
||||
return { tests, count };
|
||||
return { testDefinitions, count };
|
||||
}
|
||||
|
||||
async getOne(id: number, sharedWorkflowIds: string[]) {
|
|
@ -5,22 +5,22 @@ import { listQueryMiddleware } from '@/middlewares';
|
|||
import { getSharedWorkflowIds } from '@/public-api/v1/handlers/workflows/workflows.service';
|
||||
import { isPositiveInteger } from '@/utils';
|
||||
|
||||
import { TestsService } from './tests.service';
|
||||
import { TestsRequest } from './tests.types';
|
||||
import { TestDefinitionsService } from './test-definitions.service';
|
||||
import { TestDefinitionsRequest } from './test-definitions.types';
|
||||
|
||||
@RestController('/evaluation/tests')
|
||||
export class TestsController {
|
||||
constructor(private readonly testsService: TestsService) {}
|
||||
@RestController('/evaluation/test-definitions')
|
||||
export class TestDefinitionsController {
|
||||
constructor(private readonly testsService: TestDefinitionsService) {}
|
||||
|
||||
@Get('/', { middlewares: listQueryMiddleware })
|
||||
async getMany(req: TestsRequest.GetMany) {
|
||||
async getMany(req: TestDefinitionsRequest.GetMany) {
|
||||
const workflowIds = await getSharedWorkflowIds(req.user, ['workflow:read']);
|
||||
|
||||
return await this.testsService.getMany(req.listQueryOptions, workflowIds);
|
||||
}
|
||||
|
||||
@Get('/:id')
|
||||
async getOne(req: TestsRequest.GetOne) {
|
||||
async getOne(req: TestDefinitionsRequest.GetOne) {
|
||||
if (!isPositiveInteger(req.params.id)) {
|
||||
throw new BadRequestError('Test ID is not a number');
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ export class TestsController {
|
|||
}
|
||||
|
||||
@Post('/')
|
||||
async create(req: TestsRequest.Create) {
|
||||
async create(req: TestDefinitionsRequest.Create) {
|
||||
const workflowIds = await getSharedWorkflowIds(req.user, ['workflow:read']);
|
||||
|
||||
if (!workflowIds.includes(req.body.workflowId)) {
|
||||
|
@ -42,7 +42,7 @@ export class TestsController {
|
|||
}
|
||||
|
||||
@Delete('/:id')
|
||||
async delete(req: TestsRequest.Delete) {
|
||||
async delete(req: TestDefinitionsRequest.Delete) {
|
||||
if (!isPositiveInteger(req.params.id)) {
|
||||
throw new BadRequestError('Test ID is not a number');
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ export class TestsController {
|
|||
}
|
||||
|
||||
@Patch('/:id')
|
||||
async update(req: TestsRequest.Update) {
|
||||
async update(req: TestDefinitionsRequest.Update) {
|
||||
if (!isPositiveInteger(req.params.id)) {
|
||||
throw new BadRequestError('Test ID is not a number');
|
||||
}
|
|
@ -1,8 +1,7 @@
|
|||
import { Service } from 'typedi';
|
||||
|
||||
import type { TestDefinition } from '@/databases/entities/test-definition';
|
||||
import type { User } from '@/databases/entities/user';
|
||||
import { TestRepository } from '@/databases/repositories/test.repository';
|
||||
import { TestDefinitionRepository } from '@/databases/repositories/test-definition.repository';
|
||||
import { validateEntity } from '@/generic-helpers';
|
||||
import type { ListQuery } from '@/requests';
|
||||
|
||||
|
@ -16,8 +15,8 @@ type TestDefinitionLike = Omit<
|
|||
};
|
||||
|
||||
@Service()
|
||||
export class TestsService {
|
||||
constructor(private testRepository: TestRepository) {}
|
||||
export class TestDefinitionsService {
|
||||
constructor(private testRepository: TestDefinitionRepository) {}
|
||||
|
||||
toEntity(attrs: {
|
||||
name?: string;
|
|
@ -1,10 +1,10 @@
|
|||
import type { AuthenticatedRequest, ListQuery } from '@/requests';
|
||||
|
||||
// ----------------------------------
|
||||
// /tests
|
||||
// /test-definitions
|
||||
// ----------------------------------
|
||||
|
||||
export declare namespace TestsRequest {
|
||||
export declare namespace TestDefinitionsRequest {
|
||||
namespace RouteParams {
|
||||
type TestId = {
|
||||
id: string;
|
Loading…
Reference in a new issue