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

@ -30,6 +30,15 @@ void main() {
config.free();
});
test('returns snapshot of repository config', () {
final snapshot = repo.configSnapshot;
expect(
snapshot['remote.origin.url'].value,
'git://github.com/SkinnyMind/libgit2dart.git',
);
snapshot.free();
});
test('returns list of commits by walking from provided starting oid', () {
const log = [
'821ed6e80627b8769d170a293862f9fc60825226',
@ -111,6 +120,10 @@ void main() {
repo.setHead('refs/heads/not.there');
expect(repo.isBranchUnborn, true);
});
test('throws when target is invalid', () {
expect(() => repo.setHead(0), throwsA(isA<ArgumentError>()));
});
});
group('createBlob', () {
@ -196,6 +209,18 @@ void main() {
index.free();
});
test('cleans up state', () {
expect(repo.state, GitRepositoryState.none);
final commit = repo.lookupCommit(repo['5aecfa0']);
repo.cherryPick(commit);
expect(repo.state, GitRepositoryState.cherrypick);
repo.stateCleanup();
expect(repo.state, GitRepositoryState.none);
commit.free();
});
test('returns status of a single file for provided path', () {
final index = repo.index;
index.remove('file');
@ -284,5 +309,9 @@ void main() {
commit1.free();
commit2.free();
});
test('returns string representation of Repository object', () {
expect(repo.toString(), contains('Repository{'));
});
});
}