mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-05 04:39:07 -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
|
@ -35,6 +35,29 @@ void main() {
|
|||
initCommit.free();
|
||||
});
|
||||
|
||||
test('.single() throws when spec string not found or invalid', () {
|
||||
expect(
|
||||
() => repo.revParseSingle('invalid'),
|
||||
throwsA(
|
||||
isA<LibGit2Error>().having(
|
||||
(e) => e.toString(),
|
||||
'error',
|
||||
"revspec 'invalid' not found",
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(
|
||||
() => repo.revParseSingle(''),
|
||||
throwsA(
|
||||
isA<LibGit2Error>().having(
|
||||
(e) => e.toString(),
|
||||
'error',
|
||||
"failed to parse revision specifier - Invalid pattern ''",
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
test('.ext() returns commit and reference', () {
|
||||
final masterRef = repo.lookupReference('refs/heads/master');
|
||||
var headParse = repo.revParseExt('master');
|
||||
|
@ -70,6 +93,29 @@ void main() {
|
|||
headParse.object.free();
|
||||
});
|
||||
|
||||
test('.ext() throws when spec string not found or invalid', () {
|
||||
expect(
|
||||
() => repo.revParseExt('invalid'),
|
||||
throwsA(
|
||||
isA<LibGit2Error>().having(
|
||||
(e) => e.toString(),
|
||||
'error',
|
||||
"revspec 'invalid' not found",
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(
|
||||
() => repo.revParseExt(''),
|
||||
throwsA(
|
||||
isA<LibGit2Error>().having(
|
||||
(e) => e.toString(),
|
||||
'error',
|
||||
"failed to parse revision specifier - Invalid pattern ''",
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
test(
|
||||
'.range returns revspec with correct fields values based on provided spec',
|
||||
() {
|
||||
|
@ -108,12 +154,23 @@ void main() {
|
|||
test('throws on invalid range spec', () {
|
||||
expect(
|
||||
() => repo.revParse('invalid..5aecfa'),
|
||||
throwsA(isA<LibGit2Error>()),
|
||||
throwsA(
|
||||
isA<LibGit2Error>().having(
|
||||
(e) => e.toString(),
|
||||
'error',
|
||||
"revspec 'invalid' not found",
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(
|
||||
() => repo.revParse('master........5aecfa'),
|
||||
throwsA(isA<LibGit2Error>()),
|
||||
throwsA(
|
||||
isA<LibGit2Error>().having(
|
||||
(e) => e.toString(),
|
||||
'error',
|
||||
"failed to parse revision specifier - Invalid pattern '.....5aecfa'",
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue