Files
pipelines/app/test/features/changes/fixtures.dart
T

68 lines
1.6 KiB
Dart

import 'package:pipelines_app/core/api_gateway.dart';
/// Server-shaped fixtures shared by the Changes tests. These mirror the JSON
/// `internal/protocol.StageFileChanges` / `FileChange` writer, including quoted
/// unified headers and optional fields.
const multiHunkPatch =
'--- "a/lib/feature.dart"\n'
'+++ "b/lib/feature.dart"\n'
'@@ -1,4 +1,5 @@\n'
' context one\n'
'-old line\n'
'+new line\n'
'+added line\n'
' context two\n'
' context three\n'
'@@ -20,3 +21,2 @@\n'
' context twenty\n'
'-removed line\n'
' context twenty-two\n';
JsonMap fileChangeFixture({
required String path,
String kind = 'modified',
String patch = '',
bool binary = false,
bool truncated = false,
String? beforeMode,
String? afterMode,
}) => {
'path': path,
'kind': kind,
'patch': patch,
if (binary) 'binary': true,
if (truncated) 'truncated': true,
'before_mode': ?beforeMode,
'after_mode': ?afterMode,
};
JsonMap captureFixture({
String status = 'complete',
List<JsonMap> files = const [],
int skipped = 0,
int omitted = 0,
String diagnostic = '',
String scope = 'Git tracked and nonignored files in the run directory',
}) => {
'status': status,
'scope': scope,
'files': files,
'skipped': skipped,
'omitted': omitted,
'diagnostic': diagnostic,
};
JsonMap stepFixture({
String stage = 'implementer',
int sequence = 1,
String status = 'completed',
JsonMap? fileChanges,
int? visit,
}) => {
'stage': stage,
'sequence': sequence,
'status': status,
'file_changes': fileChanges,
if (visit != null) 'control': {'visit': visit},
};