refactor!: use Finalizer to automatically free allocated memory for objects

BREAKING CHANGE: signature change for remote and repository callbacks
during repository clone operation.
This commit is contained in:
Aleksey Kulikov 2022-04-21 14:07:11 +03:00
parent 94c40f9a94
commit b589097c8c
73 changed files with 1073 additions and 1618 deletions

View file

@ -29,8 +29,6 @@ void main() {
expect(annotated.oid, tip);
expect(annotated.refName, '');
annotated.free();
});
test('throws when trying to lookup annotated commit with invalid oid', () {
@ -49,25 +47,18 @@ void main() {
expect(annotated.oid, reference.target);
expect(annotated.refName, 'refs/heads/master');
annotated.free();
reference.free();
});
test(
'throws when trying to create annotated commit from provided '
'reference and error occurs', () {
final reference = Reference.lookup(repo: repo, name: 'refs/heads/master');
expect(
() => AnnotatedCommit.fromReference(
repo: Repository(nullptr),
reference: reference,
reference: Reference.lookup(repo: repo, name: 'refs/heads/master'),
),
throwsA(isA<LibGit2Error>()),
);
reference.free();
});
test('creates annotated commit from provided revspec', () {
@ -75,8 +66,6 @@ void main() {
expect(annotated.oid.sha, '5aecfa0fb97eadaac050ccb99f03c3fb65460ad4');
expect(annotated.refName, '');
annotated.free();
});
test('throws when trying to create annotated commit from invalid revspec',
@ -98,8 +87,6 @@ void main() {
expect(annotated.oid, oid);
expect(annotated.refName, 'master');
annotated.free();
});
test(
@ -115,5 +102,10 @@ void main() {
throwsA(isA<LibGit2Error>()),
);
});
test('manually releases allocated memory', () {
final annotated = AnnotatedCommit.lookup(repo: repo, oid: tip);
expect(() => annotated.free(), returnsNormally);
});
});
}