refactor(core): Move tag collection into repository (no-changelog) (#6860)

* refactor(core): Move tag collection into repository

* Fix tests

* Address feedback

* Fix missing spot
This commit is contained in:
Iván Ovejero
2023-08-08 14:08:56 +02:00
committed by GitHub
parent 8de28fe4d0
commit 11440bfd3c
15 changed files with 59 additions and 61 deletions

View File

@@ -35,6 +35,8 @@ import type { ExecutionData } from '@db/entities/ExecutionData';
import { generateNanoId } from '@db/utils/generators';
import { RoleService } from '@/services/role.service';
import { VariablesService } from '@/environments/variables/variables.service';
import { TagRepository } from '@/databases/repositories';
import { separate } from '@/utils';
export type TestDBType = 'postgres' | 'mysql';
@@ -113,7 +115,13 @@ export async function terminate() {
* Truncate specific DB tables in a test DB.
*/
export async function truncate(collections: CollectionName[]) {
for (const collection of collections) {
const [tag, rest] = separate(collections, (c) => c === 'Tag');
if (tag) {
await Container.get(TagRepository).delete({});
}
for (const collection of rest) {
await Db.collections[collection].delete({});
}
}
@@ -384,7 +392,7 @@ export async function createWaitingExecution(workflow: WorkflowEntity) {
export async function createTag(attributes: Partial<TagEntity> = {}) {
const { name } = attributes;
return Db.collections.Tag.save({
return Container.get(TagRepository).save({
id: generateNanoId(),
name: name ?? randomName(),
...attributes,