import 'package:test/test.dart'; import '../../tool/src/release/log.dart'; import '../../tool/src/release/version.dart'; void main() { test("git's log is read as commits with their bodies and files", () { // As `git log --format= --name-only` writes it. const output = '\x1eaaa111\x1ffeat(app): one\x1fWhy it matters.\n\n' 'BREAKING CHANGE: older apps stop.\n\x1f\n\n' 'apps/notes/a.dart\npackages/halkyon_ui/b.dart\n' '\x1ebbb222\x1fchore: merge\x1f\x1f\n' '\x1eccc333\x1ffix: two\x1f\x1f\n\npubspec.lock\n'; final commits = parseLog(output); expect(commits.map((commit) => commit.hash), [ 'aaa111', 'bbb222', 'ccc333', ]); expect(commits.first.subject, 'feat(app): one'); expect(isBreaking(commits.first), isTrue); expect(commits.first.files, [ 'apps/notes/a.dart', 'packages/halkyon_ui/b.dart', ]); // A merge lists no files of its own. expect(commits[1].files, isEmpty); expect(commits[2].files, ['pubspec.lock']); }); test('no commits, no output', () { expect(parseLog(''), isEmpty); }); }