mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-04 20:29:08 -04:00
test(tree): add test for tree creation
This commit is contained in:
parent
139c477d4a
commit
ebfc67ee0d
3 changed files with 19 additions and 1 deletions
|
@ -11,5 +11,6 @@ export 'src/signature.dart';
|
|||
export 'src/revwalk.dart';
|
||||
export 'src/blob.dart';
|
||||
export 'src/tag.dart';
|
||||
export 'src/treebuilder.dart';
|
||||
export 'src/error.dart';
|
||||
export 'src/enums.dart';
|
||||
|
|
|
@ -67,5 +67,23 @@ void main() {
|
|||
test('throws when nothing found for provided path', () {
|
||||
expect(() => tree['invalid/path'], throwsA(isA<LibGit2Error>()));
|
||||
});
|
||||
|
||||
test('successfully creates tree', () {
|
||||
final fileOid = repo.createBlob('blob content');
|
||||
final builder = TreeBuilder(repo);
|
||||
|
||||
builder.add('filename', fileOid, GitFilemode.blob);
|
||||
final newTree = Tree.lookup(repo, builder.write());
|
||||
|
||||
final entry = newTree['filename'];
|
||||
expect(newTree.length, 1);
|
||||
expect(entry.name, 'filename');
|
||||
expect(entry.filemode, GitFilemode.blob);
|
||||
expect(entry.id, fileOid);
|
||||
|
||||
builder.free();
|
||||
entry.free();
|
||||
newTree.free();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ import 'dart:io';
|
|||
|
||||
import 'package:test/test.dart';
|
||||
import 'package:libgit2dart/libgit2dart.dart';
|
||||
import 'package:libgit2dart/src/treebuilder.dart';
|
||||
import 'helpers/util.dart';
|
||||
|
||||
void main() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue