test(reference): free up proper objects

This commit is contained in:
Aleksey Kulikov 2021-08-09 17:14:34 +03:00
parent ef29257f2e
commit 9a737f8d3e

View file

@ -254,8 +254,9 @@ void main() {
}); });
test('returns correct type of reference', () { test('returns correct type of reference', () {
expect(repo.head.type, ReferenceType.direct); final head = repo.head;
repo.head.free(); expect(head.type, ReferenceType.direct);
head.free();
final ref = Reference.get(repo, 'HEAD'); final ref = Reference.get(repo, 'HEAD');
expect(ref.type, ReferenceType.symbolic); expect(ref.type, ReferenceType.symbolic);
@ -263,8 +264,9 @@ void main() {
}); });
test('returns SHA hex of direct reference', () { test('returns SHA hex of direct reference', () {
expect(repo.head.target.sha, lastCommit); final head = repo.head;
repo.head.free(); expect(head.target.sha, lastCommit);
head.free();
}); });
test('returns SHA hex of symbolic reference', () { test('returns SHA hex of symbolic reference', () {
@ -274,8 +276,9 @@ void main() {
}); });
test('returns the full name', () { test('returns the full name', () {
expect(repo.head.name, 'refs/heads/master'); final head = repo.head;
repo.head.free(); expect(head.name, 'refs/heads/master');
head.free();
}); });
test('returns the short name', () { test('returns the short name', () {
@ -285,10 +288,12 @@ void main() {
target: lastCommit, target: lastCommit,
); );
expect(repo.head.shorthand, 'master'); final head = repo.head;
expect(head.shorthand, 'master');
expect(ref.shorthand, 'origin/master'); expect(ref.shorthand, 'origin/master');
repo.head.free(); head.free();
ref.free(); ref.free();
}); });