CockpitTestReportExecution constructor
CockpitTestReportExecution({
- required CockpitTestReportExecutionRole role,
- String? entryId,
- int? attemptNumber,
- required CockpitTestAttemptResult result,
- Iterable<
CockpitTestReportArtifact> artifacts = const <CockpitTestReportArtifact>[],
Creates a CockpitTestReportExecution.
Implementation
CockpitTestReportExecution({
required this.role,
this.entryId,
this.attemptNumber,
required this.result,
Iterable<CockpitTestReportArtifact> artifacts =
const <CockpitTestReportArtifact>[],
}) : artifacts = List<CockpitTestReportArtifact>.unmodifiable(artifacts) {
if ((entryId == null) != (attemptNumber == null) ||
attemptNumber != null && attemptNumber! < 1) {
throw const FormatException(
'Linked report execution identity is incomplete.',
);
}
if (entryId != null) {
CockpitTestValueReader.string(entryId, r'$.entryId', id: true);
}
final evidenceIds = <String>{};
final resourceIds = <String>{};
final paths = <String>{};
for (final artifact in this.artifacts) {
if (artifact.attemptId != result.context.attemptId ||
!evidenceIds.add(artifact.evidenceId) ||
!resourceIds.add(artifact.resourceId) ||
!paths.add(artifact.relativePath)) {
throw const FormatException(
'Report execution artifact identity is invalid or duplicated.',
);
}
}
for (final step in result.steps) {
if (!step.evidence.every(evidenceIds.contains)) {
throw FormatException(
'Step ${step.executionId} references missing report evidence.',
);
}
}
}