CockpitTestReportBundle constructor

CockpitTestReportBundle({
  1. String schemaVersion = 'cockpit.report.bundle/v2',
  2. required DateTime generatedAt,
  3. required CockpitTestSuiteReport report,
  4. required Iterable<CockpitTestReportExecution> executions,
  5. bool complete = true,
})

Creates a CockpitTestReportBundle.

Implementation

CockpitTestReportBundle({
  this.schemaVersion = 'cockpit.report.bundle/v2',
  required this.generatedAt,
  required this.report,
  required Iterable<CockpitTestReportExecution> executions,
  this.complete = true,
}) : executions = List<CockpitTestReportExecution>.unmodifiable(executions) {
  if (schemaVersion != 'cockpit.report.bundle/v2' ||
      !generatedAt.isUtc ||
      !complete) {
    throw const FormatException('Offline report bundle is incomplete.');
  }
  final attemptIds = <String>{};
  final resourceIds = <String>{};
  final paths = <String>{};
  for (final execution in this.executions) {
    if (execution.result.context.runId != report.runId ||
        execution.result.context.workspaceId != report.workspaceId ||
        !attemptIds.add(execution.result.context.attemptId)) {
      throw const FormatException(
        'Report execution crosses bundle authority or is duplicated.',
      );
    }
    for (final artifact in execution.artifacts) {
      if (!resourceIds.add(artifact.resourceId) ||
          !paths.add(artifact.relativePath)) {
        throw const FormatException(
          'Offline report contains duplicate artifact identity.',
        );
      }
    }
  }
}