test: improve coverage

This commit is contained in:
Aleksey Kulikov 2021-10-15 17:37:38 +03:00
parent d75acbfdd3
commit d6eae1e9ed
71 changed files with 710 additions and 229 deletions

View file

@ -34,17 +34,16 @@ void main() {
});
test('successfully adds disk alternate', () {
final oid = Oid.fromSHA(repo: repo, sha: blobSha);
final odb = Odb.create();
odb.addDiskAlternate('${repo.workdir}.git/objects/');
expect(odb.contains(oid), true);
expect(odb.contains(repo[blobSha]), true);
odb.free();
});
test('successfully reads object', () {
final oid = Oid.fromSHA(repo: repo, sha: blobSha);
final oid = repo[blobSha];
final odb = repo.odb;
final object = odb.read(oid);
@ -58,23 +57,14 @@ void main() {
});
test('returns list of all objects oid\'s in database', () {
final oid = Oid.fromSHA(repo: repo, sha: commitSha);
final odb = repo.odb;
expect(odb.objects, isNot(isEmpty));
expect(odb.objects.contains(oid), true);
expect(odb.objects.contains(repo[commitSha]), true);
odb.free();
});
test('finds object by short oid', () {
final oid = Oid.fromSHA(
repo: repo,
sha: commitSha.substring(0, 5),
);
expect(oid.sha, commitSha);
});
test('successfully writes data', () {
final odb = repo.odb;
final oid = odb.write(type: GitObject.blob, data: 'testing');
@ -96,5 +86,12 @@ void main() {
odb.free();
});
test('returns string representation of OdbObject object', () {
final odb = repo.odb;
final object = odb.read(repo[blobSha]);
expect(object.toString(), contains('OdbObject{'));
odb.free();
});
});
}