mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-04 20:29:08 -04:00
test: add more tests for throws and their messages
This commit is contained in:
parent
d6eae1e9ed
commit
127849519d
80 changed files with 2741 additions and 1501 deletions
|
@ -23,21 +23,61 @@ void main() {
|
|||
File('${tmpDir.path}/feature_file').writeAsStringSync('edit');
|
||||
expect(repo.status, contains('feature_file'));
|
||||
|
||||
repo.checkout(refName: 'HEAD', strategy: {GitCheckout.force});
|
||||
repo.checkout(
|
||||
refName: 'HEAD',
|
||||
strategy: {GitCheckout.force},
|
||||
paths: ['feature_file'],
|
||||
);
|
||||
expect(repo.status, isEmpty);
|
||||
});
|
||||
|
||||
test(
|
||||
'throws when trying to checkout head with invalid alternative directory',
|
||||
() {
|
||||
expect(
|
||||
() => repo.checkout(
|
||||
refName: 'HEAD',
|
||||
directory: 'not/there',
|
||||
),
|
||||
throwsA(
|
||||
isA<LibGit2Error>().having(
|
||||
(e) => e.toString(),
|
||||
'error',
|
||||
"failed to make directory 'not/there': No such file or directory",
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
test('successfully checkouts index', () {
|
||||
File('${repo.workdir}feature_file').writeAsStringSync('edit');
|
||||
expect(repo.status, contains('feature_file'));
|
||||
|
||||
repo.checkout(strategy: {
|
||||
GitCheckout.force,
|
||||
GitCheckout.conflictStyleMerge,
|
||||
});
|
||||
repo.checkout(
|
||||
strategy: {
|
||||
GitCheckout.force,
|
||||
GitCheckout.conflictStyleMerge,
|
||||
},
|
||||
paths: ['feature_file'],
|
||||
);
|
||||
expect(repo.status, isEmpty);
|
||||
});
|
||||
|
||||
test(
|
||||
'throws when trying to checkout index with invalid alternative directory',
|
||||
() {
|
||||
expect(
|
||||
() => repo.checkout(directory: 'not/there'),
|
||||
throwsA(
|
||||
isA<LibGit2Error>().having(
|
||||
(e) => e.toString(),
|
||||
'error',
|
||||
"failed to make directory 'not/there': No such file or directory",
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
test('successfully checkouts tree', () {
|
||||
final masterHead = repo.lookupCommit(
|
||||
repo['821ed6e80627b8769d170a293862f9fc60825226'],
|
||||
|
@ -68,6 +108,24 @@ void main() {
|
|||
masterHead.free();
|
||||
});
|
||||
|
||||
test(
|
||||
'throws when trying to checkout tree with invalid alternative directory',
|
||||
() {
|
||||
expect(
|
||||
() => repo.checkout(
|
||||
refName: 'refs/heads/feature',
|
||||
directory: 'not/there',
|
||||
),
|
||||
throwsA(
|
||||
isA<LibGit2Error>().having(
|
||||
(e) => e.toString(),
|
||||
'error',
|
||||
"failed to make directory 'not/there': No such file or directory",
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
test('successfully checkouts with alrenative directory', () {
|
||||
final altDir = Directory('${Directory.systemTemp.path}/alt_dir');
|
||||
// making sure there is no directory
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue