Now creating a test contact

ref #110
This commit is contained in:
Nicolai Ort 2021-01-20 17:38:34 +01:00
parent eab0e634a2
commit 1837336865
1 changed files with 19 additions and 0 deletions

View File

@ -1,9 +1,11 @@
import { Connection } from 'typeorm';
import { Factory, Seeder } from 'typeorm-seeding';
import { CreateGroupContact } from '../models/actions/create/CreateGroupContact';
import { CreateRunner } from '../models/actions/create/CreateRunner';
import { CreateRunnerOrganisation } from '../models/actions/create/CreateRunnerOrganisation';
import { CreateRunnerTeam } from '../models/actions/create/CreateRunnerTeam';
import { Address } from '../models/entities/Address';
import { GroupContact } from '../models/entities/GroupContact';
import { Runner } from '../models/entities/Runner';
import { RunnerGroup } from '../models/entities/RunnerGroup';
import { RunnerOrganisation } from '../models/entities/RunnerOrganisation';
@ -17,6 +19,7 @@ export default class SeedTestRunners implements Seeder {
public async run(factory: Factory, connection: Connection): Promise<any> {
let testOrg: RunnerOrganisation = await this.createTestOrg(connection);
let testTeam: RunnerTeam = await this.createTestTeam(connection, testOrg);
await this.createTestContact(connection, testOrg);
await this.createTestRunners(connection, testOrg);
await this.createTestRunners(connection, testTeam);
}
@ -55,6 +58,22 @@ export default class SeedTestRunners implements Seeder {
}
}
public async createTestContact(connection: Connection, group: RunnerGroup) {
let contact = new CreateGroupContact;
contact.firstname = "Test";
contact.lastname = "Contact";
contact.email = "test.contact@dev.lauf-fuer-kaya.de";
contact.groups = group.id;
contact.address = new Address();
contact.address.address1 = "First Contact Street 100";
contact.address.city = "Herzogenaurach";
contact.address.country = "Germany";
contact.address.postalcode = "90174";
await connection.getRepository(GroupContact).save(await contact.toEntity());
}
private firstnames = [
"Peter",
"Matze",