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

@ -42,12 +42,13 @@ void main() {
expect(tag.message, 'annotated tag\n');
expect(target.message, 'add subdirectory file\n');
expect(tagger, signature);
expect(tag.toString(), contains('Tag{'));
signature.free();
target.free();
});
test('successfully creates new tag', () {
test('successfully creates new tag with commit as target', () {
final signature = Signature.create(
name: 'Author',
email: 'author@email.com',
@ -80,6 +81,104 @@ void main() {
signature.free();
});
test('successfully creates new tag with tree as target', () {
final signature = Signature.create(
name: 'Author',
email: 'author@email.com',
time: 1234,
);
const tagName = 'tag';
final target = repo['a8ae3dd59e6e1802c6f78e05e301bfd57c9f334f'];
const message = 'init tag\n';
final oid = repo.createTag(
tagName: tagName,
target: target,
targetType: GitObject.tree,
tagger: signature,
message: message,
);
final newTag = repo.lookupTag(oid);
final tagger = newTag.tagger;
final newTagTarget = newTag.target as Tree;
expect(newTag.oid.sha, 'ca715c0bafad5d39d568675aad69f71a82178416');
expect(newTag.name, tagName);
expect(newTag.message, message);
expect(tagger, signature);
expect(newTagTarget.oid, target);
newTag.free();
newTagTarget.free();
signature.free();
});
test('successfully creates new tag with blob as target', () {
final signature = Signature.create(
name: 'Author',
email: 'author@email.com',
time: 1234,
);
const tagName = 'tag';
final target = repo['9c78c21d6680a7ffebc76f7ac68cacc11d8f48bc'];
const message = 'init tag\n';
final oid = repo.createTag(
tagName: tagName,
target: target,
targetType: GitObject.blob,
tagger: signature,
message: message,
);
final newTag = repo.lookupTag(oid);
final tagger = newTag.tagger;
final newTagTarget = newTag.target as Blob;
expect(newTag.oid.sha, '8b1edabda95e934d2252e563219315b08e38dce5');
expect(newTag.name, tagName);
expect(newTag.message, message);
expect(tagger, signature);
expect(newTagTarget.oid, target);
newTag.free();
newTagTarget.free();
signature.free();
});
test('successfully creates new tag with tag as target', () {
final signature = Signature.create(
name: 'Author',
email: 'author@email.com',
time: 1234,
);
const tagName = 'tag';
const message = 'init tag\n';
final oid = repo.createTag(
tagName: tagName,
target: tag.oid,
targetType: GitObject.tag,
tagger: signature,
message: message,
);
final newTag = repo.lookupTag(oid);
final tagger = newTag.tagger;
final newTagTarget = newTag.target as Tag;
expect(newTag.oid.sha, '20286cf6c3b150b58b6c419814b0931d9b17c2ba');
expect(newTag.name, tagName);
expect(newTag.message, message);
expect(tagger, signature);
expect(newTagTarget.oid, tag.oid);
newTag.free();
newTagTarget.free();
signature.free();
});
test('returns list of tags in repository', () {
expect(Tag.list(repo), ['v0.1', 'v0.2']);
});