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
|
@ -1,3 +1,4 @@
|
|||
import 'dart:ffi';
|
||||
import 'dart:io';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:libgit2dart/libgit2dart.dart';
|
||||
|
@ -43,6 +44,20 @@ void main() {
|
|||
}
|
||||
});
|
||||
|
||||
test('throws when trying to get list of notes and error occurs', () {
|
||||
Directory('${repo.workdir}.git/refs/notes').deleteSync(recursive: true);
|
||||
expect(
|
||||
() => repo.notes,
|
||||
throwsA(
|
||||
isA<LibGit2Error>().having(
|
||||
(e) => e.toString(),
|
||||
'error',
|
||||
"reference 'refs/notes/commits' not found",
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
test('successfully lookups note', () {
|
||||
final head = repo.head;
|
||||
final note = repo.lookupNote(annotatedOid: head.target);
|
||||
|
@ -75,7 +90,25 @@ void main() {
|
|||
signature.free();
|
||||
});
|
||||
|
||||
test('successfully removes note', () {
|
||||
test('throws when trying to create note and error occurs', () {
|
||||
expect(
|
||||
() => Repository(nullptr).createNote(
|
||||
author: Signature(nullptr),
|
||||
committer: Signature(nullptr),
|
||||
annotatedOid: repo['0' * 40],
|
||||
note: '',
|
||||
),
|
||||
throwsA(
|
||||
isA<LibGit2Error>().having(
|
||||
(e) => e.toString(),
|
||||
'error',
|
||||
"invalid argument: 'repo'",
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
test('successfully deletes note', () {
|
||||
final signature = repo.defaultSignature;
|
||||
final head = repo.head;
|
||||
|
||||
|
@ -87,13 +120,36 @@ void main() {
|
|||
|
||||
expect(
|
||||
() => repo.lookupNote(annotatedOid: head.target),
|
||||
throwsA(isA<LibGit2Error>()),
|
||||
throwsA(
|
||||
isA<LibGit2Error>().having(
|
||||
(e) => e.toString(),
|
||||
'error',
|
||||
"note could not be found",
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
head.free();
|
||||
signature.free();
|
||||
});
|
||||
|
||||
test('throws when trying to delete note and error occurs', () {
|
||||
expect(
|
||||
() => Repository(nullptr).deleteNote(
|
||||
author: Signature(nullptr),
|
||||
committer: Signature(nullptr),
|
||||
annotatedOid: repo['0' * 40],
|
||||
),
|
||||
throwsA(
|
||||
isA<LibGit2Error>().having(
|
||||
(e) => e.toString(),
|
||||
'error',
|
||||
"invalid argument: 'repo'",
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
test('returns string representation of Note object', () {
|
||||
final note = repo.lookupNote(annotatedOid: repo['821ed6e']);
|
||||
expect(note.toString(), contains('Note{'));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue