mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-04 20:29:08 -04:00
feat(reference): add ability to create direct reference
This commit is contained in:
parent
6643527f2d
commit
9190ed2e0f
16 changed files with 669 additions and 60 deletions
46
test/odb_test.dart
Normal file
46
test/odb_test.dart
Normal file
|
@ -0,0 +1,46 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:test/test.dart';
|
||||
import 'package:libgit2dart/src/repository.dart';
|
||||
import 'package:libgit2dart/src/odb.dart';
|
||||
import 'package:libgit2dart/src/oid.dart';
|
||||
|
||||
import 'helpers/util.dart';
|
||||
|
||||
void main() {
|
||||
const lastCommit = '78b8bf123e3952c970ae5c1ce0a3ea1d1336f6e8';
|
||||
|
||||
group('Odb', () {
|
||||
late Repository repo;
|
||||
final tmpDir = '${Directory.systemTemp.path}/odb_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);
|
||||
});
|
||||
|
||||
tearDownAll(() async {
|
||||
repo.close();
|
||||
await Directory(tmpDir).delete(recursive: true);
|
||||
});
|
||||
|
||||
test('successfully initializes', () {
|
||||
expect(repo.odb, isA<Odb>());
|
||||
repo.odb.free();
|
||||
});
|
||||
|
||||
test('finds object by short oid', () {
|
||||
final shortSha = '78b8bf';
|
||||
final shortOid = Oid.fromSHAn(shortSha);
|
||||
final oid = repo.odb.existsPrefix(shortOid.pointer, shortSha.length);
|
||||
expect(Oid(oid).sha, lastCommit);
|
||||
repo.odb.free();
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue