mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-05 04:39:07 -04:00
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:
parent
94c40f9a94
commit
b589097c8c
73 changed files with 1073 additions and 1618 deletions
|
@ -43,7 +43,6 @@ void main() {
|
|||
expect(notes[i].oid.sha, notesExpected[i]['oid']);
|
||||
expect(notes[i].message, notesExpected[i]['message']);
|
||||
expect(notes[i].annotatedOid.sha, notesExpected[i]['annotatedOid']);
|
||||
notes[i].free();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -53,15 +52,11 @@ void main() {
|
|||
});
|
||||
|
||||
test('lookups note', () {
|
||||
final head = repo.head;
|
||||
final note = Note.lookup(repo: repo, annotatedOid: head.target);
|
||||
final note = Note.lookup(repo: repo, annotatedOid: repo.head.target);
|
||||
|
||||
expect(note.oid.sha, notesExpected[1]['oid']);
|
||||
expect(note.message, notesExpected[1]['message']);
|
||||
expect(note.annotatedOid.sha, notesExpected[1]['annotatedOid']);
|
||||
|
||||
note.free();
|
||||
head.free();
|
||||
});
|
||||
|
||||
test('creates note', () {
|
||||
|
@ -70,12 +65,11 @@ void main() {
|
|||
email: 'author@email.com',
|
||||
time: 1234,
|
||||
);
|
||||
final head = repo.head;
|
||||
final noteOid = Note.create(
|
||||
repo: repo,
|
||||
author: signature,
|
||||
committer: signature,
|
||||
annotatedOid: head.target,
|
||||
annotatedOid: repo.head.target,
|
||||
note: 'New note for HEAD',
|
||||
force: true,
|
||||
);
|
||||
|
@ -83,10 +77,6 @@ void main() {
|
|||
|
||||
expect(noteOid.sha, 'ffd6e2ceaf91c00ea6d29e2e897f906da720529f');
|
||||
expect(noteBlob.content, 'New note for HEAD');
|
||||
|
||||
noteBlob.free();
|
||||
head.free();
|
||||
signature.free();
|
||||
});
|
||||
|
||||
test('throws when trying to create note and error occurs', () {
|
||||
|
@ -108,7 +98,6 @@ void main() {
|
|||
email: 'author@email.com',
|
||||
time: 1234,
|
||||
);
|
||||
final head = repo.head;
|
||||
|
||||
Note.delete(
|
||||
repo: repo,
|
||||
|
@ -118,12 +107,9 @@ void main() {
|
|||
);
|
||||
|
||||
expect(
|
||||
() => Note.lookup(repo: repo, annotatedOid: head.target),
|
||||
() => Note.lookup(repo: repo, annotatedOid: repo.head.target),
|
||||
throwsA(isA<LibGit2Error>()),
|
||||
);
|
||||
|
||||
head.free();
|
||||
signature.free();
|
||||
});
|
||||
|
||||
test('throws when trying to delete note and error occurs', () {
|
||||
|
@ -138,10 +124,14 @@ void main() {
|
|||
);
|
||||
});
|
||||
|
||||
test('manually releases allocated memory', () {
|
||||
final note = Note.lookup(repo: repo, annotatedOid: repo['821ed6e']);
|
||||
expect(() => note.free(), returnsNormally);
|
||||
});
|
||||
|
||||
test('returns string representation of Note object', () {
|
||||
final note = Note.lookup(repo: repo, annotatedOid: repo['821ed6e']);
|
||||
expect(note.toString(), contains('Note{'));
|
||||
note.free();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue