feat(reference): add ability to create direct reference

This commit is contained in:
Aleksey Kulikov 2021-08-05 19:48:58 +03:00
parent 6643527f2d
commit 9190ed2e0f
16 changed files with 669 additions and 60 deletions

56
test/reflog_test.dart Normal file
View file

@ -0,0 +1,56 @@
import 'dart:io';
import 'package:test/test.dart';
import 'package:libgit2dart/src/repository.dart';
import 'package:libgit2dart/src/reflog.dart';
import 'helpers/util.dart';
void main() {
group('RefLog', () {
late final Repository repo;
late final RefLog reflog;
final tmpDir = '${Directory.systemTemp.path}/reflog_testrepo/';
setUpAll(() async {
if (await Directory(tmpDir).exists()) {
await Directory(tmpDir).delete(recursive: true);
}
await copyRepo(
from: Directory('test/assets/testrepo/'),
to: await Directory(tmpDir).create(),
);
repo = Repository.open(tmpDir);
reflog = RefLog(repo.head);
});
tearDownAll(() async {
repo.head.free();
reflog.free();
repo.close();
await Directory(tmpDir).delete(recursive: true);
});
test('initializes successfully', () {
expect(reflog, isA<RefLog>());
});
test('returns correct number of log entries', () {
expect(reflog.count, 3);
});
test('returns the log message', () {
final entry = reflog.entryAt(0);
expect(
entry.message,
"merge feature: Merge made by the 'recursive' strategy.",
);
});
test('returns the committer of the entry', () {
final entry = reflog.entryAt(0);
expect(entry.committer['name'], 'Aleksey Kulikov');
expect(entry.committer['email'], 'skinny.mind@gmail.com');
});
});
}