added trackscan update tests
All checks were successful
continuous-integration/drone/pr Build is passing

ref #78
This commit is contained in:
2021-01-09 17:18:33 +01:00
parent efe1a1f543
commit 7e95103a2d
2 changed files with 245 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
import { IsBoolean, IsInt, IsOptional, IsPositive } from 'class-validator';
import { IsBoolean, IsInt, IsOptional } from 'class-validator';
import { getConnection } from 'typeorm';
import { RunnerNotFoundError } from '../../errors/RunnerErrors';
import { ScanStationNotFoundError } from '../../errors/ScanStationErrors';
@@ -22,8 +22,8 @@ export abstract class UpdateTrackScan {
* This is important to link ran distances to runners.
*/
@IsInt()
@IsPositive()
runner: number;
@IsOptional()
runner?: number;
/**
* Is the updated scan valid (for fraud reasons).
@@ -46,7 +46,9 @@ export abstract class UpdateTrackScan {
*/
public async updateScan(scan: TrackScan): Promise<TrackScan> {
scan.valid = this.valid;
scan.runner = await this.getRunner();
if (this.runner) {
scan.runner = await this.getRunner();
}
if (this.station) {
scan.station = await this.getStation();
}