processSaveIntegrationRequest method

Future<void> processSaveIntegrationRequest(
  1. FileSystemEntity file,
  2. AnalysisContextCollection collection,
  3. PubspecData pubspecData, {
  4. required String className,
  5. required DartServerRepository dartServerRepository,
  6. int? index,
})

Implementation

Future<void> processSaveIntegrationRequest(
  FileSystemEntity file,
  AnalysisContextCollection collection,
  PubspecData pubspecData, {
  required String className,
  required DartServerRepository dartServerRepository,
  int? index,
}) async {
  wtLog.startSpinner("Getting ready...");
  try {
    final testInputs = await _prepareIntegrationTestInputs(file, collection);

    for (var test in testInputs) {
      if (test.moduleName != className) continue;

      for (var i = 0; i < test.testFlows.length; i++) {
        if (index != null && i != index) {
          continue;
        }
        final integrationSaver =
            IntegrationSaver(dartServerRepository: dartServerRepository)
              ..init();

        await integrationSaver.saveTestFlow(
            testInput: test,
            allTests: testInputs,
            index: i,
            pubspecData: pubspecData,
            collection: collection);
      }
    }
  } catch (e, stackTrace) {
    wtTelemetry.trackError(
        severity: Severity.error, error: e, stackTrace: stackTrace);
    wtLog.warning("Error saving integration tests for file: ${file.path}");
    wtLog.log(e.toString());
  } finally {
    wtLog.stopSpinner();
    return;
  }
}