test sweep: finish src/git/ (T-91)
test / unit + widget + golden + a11y (push) Failing after 30s
test / integration_test (xvfb) (push) Has been skipped
test / bundle smoke (xvfb 5s) (push) Has been skipped
test / daemon subprocess + web WASM smoke (push) Has been skipped
test / dart doc (lib API) (push) Failing after 1m1s
test / unit + widget + golden + a11y (push) Failing after 30s
test / integration_test (xvfb) (push) Has been skipped
test / bundle smoke (xvfb 5s) (push) Has been skipped
test / daemon subprocess + web WASM smoke (push) Has been skipped
test / dart doc (lib API) (push) Failing after 1m1s
Closes out the three remaining files in src/git/ following the client.dart batch: operations.dart (25 new tests): - GitException.toString - GitLogEntry.toJson (body present + absent) - gitStage / gitUnstage / gitStashPop / gitPush / gitPull error paths (no remote, empty stash, bogus path) - gitUnstage with empty paths (unstage everything) - gitStageHunk + gitUnstageHunk via _applyPatch - _applyPatch surfaces stderr in GitException on a bad patch - gitBranches happy + non-repo - gitCheckout happy + unknown-branch error - gitPull + gitPush round-trip against a local bare remote - gitLog / gitCurrentBranch / gitBranches non-repo fallbacks - gitDiscard with empty list short-circuit - gitBin resolver diff.dart (7 new tests): - gitDiff with paths argument and non-repo fallback - GitHunk.toPatch round-tripping header + every DiffLineKind - GitDiff.toJson with / without oldPath - parseDiffOutput edge cases: pre-diff garbage skipped, "\ No newline" marker captured as a header line, malformed @@ header skipped via _parseHunk null return status.dart (4 new tests): - branch.upstream + branch.ab populated from a local bare remote - non-git directory returns an empty branchless status - rename in porcelain output captures the original path - parsePorcelainV1 short-part / empty-part / empty-input edge cases Coverage: src/git/diff.dart 106/124 -> 124/124 (100%); src/git/operations.dart 88/155 -> 148/155 (95% — remaining 7 lines are gitPull/gitPush variants that need credentials, and the gitBranches non-zero stderr path); src/git/status.dart 86/98 -> 95/98 (97% — remaining 3 are the ProcessException-during-call catch branches, only reachable if git crashes mid-call). Total coverage 76.04% -> 77.05%; floor bumped to 77. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -92,4 +92,45 @@ void main() {
|
||||
expect(status.ahead, isZero);
|
||||
expect(status.behind, isZero);
|
||||
});
|
||||
|
||||
test('branch.upstream + branch.ab populate upstream/ahead/behind', () async {
|
||||
final remote = await Directory.systemTemp.createTemp('clide-status-remote-');
|
||||
addTearDown(() => remote.deleteSync(recursive: true));
|
||||
await Process.run('git', ['init', '--bare'], workingDirectory: remote.path);
|
||||
await Process.run('git', ['remote', 'add', 'origin', remote.path], workingDirectory: sandbox.path);
|
||||
await Process.run('git', ['push', '-u', 'origin', 'HEAD'], workingDirectory: sandbox.path);
|
||||
// Add a commit so we have ahead > 0.
|
||||
await File('${sandbox.path}/ahead.txt').writeAsString('x');
|
||||
await Process.run('git', ['add', '.'], workingDirectory: sandbox.path);
|
||||
await Process.run('git', ['commit', '-m', 'ahead'], workingDirectory: sandbox.path);
|
||||
final s = await gitStatus(sandbox);
|
||||
expect(s.upstream, contains('origin/'));
|
||||
expect(s.ahead, 1);
|
||||
expect(s.behind, 0);
|
||||
});
|
||||
|
||||
test('gitStatus on a non-git directory returns an empty branchless status', () async {
|
||||
final notGit = await Directory.systemTemp.createTemp('clide-status-not-');
|
||||
addTearDown(() => notGit.deleteSync(recursive: true));
|
||||
final s = await gitStatus(notGit);
|
||||
expect(s.entries, isEmpty);
|
||||
});
|
||||
|
||||
test('rename in porcelain output captures the original path', () async {
|
||||
await File('${sandbox.path}/a.txt').writeAsString('content\n');
|
||||
await Process.run('git', ['add', '.'], workingDirectory: sandbox.path);
|
||||
await Process.run('git', ['commit', '-m', 'add a'], workingDirectory: sandbox.path);
|
||||
await Process.run('git', ['mv', 'a.txt', 'renamed.txt'], workingDirectory: sandbox.path);
|
||||
final s = await gitStatus(sandbox);
|
||||
final renamed = s.entries.firstWhere((e) => e.path == 'renamed.txt');
|
||||
expect(renamed.origPath, 'a.txt');
|
||||
});
|
||||
|
||||
test('parsePorcelainV1 handles empty input + short / empty parts', () {
|
||||
expect(parsePorcelainV1(''), isEmpty);
|
||||
// 'X' is too short (< 4 chars), should be skipped.
|
||||
expect(parsePorcelainV1('X\x00'), isEmpty);
|
||||
// Empty token-only input — skipped.
|
||||
expect(parsePorcelainV1('\x00'), isEmpty);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user