mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-04 20:29:08 -04:00
test(repository): test against repo copied into tmp directory
This commit is contained in:
parent
9acf3a8a9e
commit
be680595bc
50 changed files with 1021 additions and 107 deletions
|
@ -3,6 +3,7 @@ import 'dart:io';
|
|||
import 'package:test/test.dart';
|
||||
import 'package:libgit2dart/src/repository.dart';
|
||||
import 'package:libgit2dart/src/error.dart';
|
||||
import 'helpers/util.dart';
|
||||
|
||||
void main() {
|
||||
late Repository repo;
|
||||
|
@ -15,116 +16,146 @@ void main() {
|
|||
);
|
||||
});
|
||||
|
||||
group('bare', () {
|
||||
setUp(() {
|
||||
repo = Repository.open('test/assets/empty_bare.git');
|
||||
group('empty', () {
|
||||
group('bare', () {
|
||||
setUp(() {
|
||||
repo = Repository.open('test/assets/empty_bare.git');
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
repo.close();
|
||||
});
|
||||
|
||||
test('opens successfully', () {
|
||||
expect(repo, isA<Repository>());
|
||||
});
|
||||
|
||||
test('checks if it is bare', () {
|
||||
expect(repo.isBare, true);
|
||||
});
|
||||
|
||||
test('returns path to the repository', () {
|
||||
expect(
|
||||
repo.path,
|
||||
'${Directory.current.path}/test/assets/empty_bare.git/',
|
||||
);
|
||||
});
|
||||
|
||||
test('returns path to root directory for the repository', () {
|
||||
expect(
|
||||
repo.commonDir,
|
||||
'${Directory.current.path}/test/assets/empty_bare.git/',
|
||||
);
|
||||
});
|
||||
|
||||
test('returns empty string as path of the working directory', () {
|
||||
expect(repo.workdir, '');
|
||||
});
|
||||
|
||||
group('setHead', () {
|
||||
test('throws when reference doesn\'t exist', () {
|
||||
expect(
|
||||
() => repo.setHead('refs/tags/doesnt/exist'),
|
||||
throwsA(isA<LibGit2Error>()),
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
repo.close();
|
||||
});
|
||||
group('standard', () {
|
||||
setUp(() {
|
||||
repo = Repository.open('test/assets/empty_standard/.gitdir/');
|
||||
});
|
||||
|
||||
test('opens successfully', () {
|
||||
expect(repo, isA<Repository>());
|
||||
});
|
||||
tearDown(() {
|
||||
repo.close();
|
||||
});
|
||||
|
||||
test('checks if it is bare', () {
|
||||
expect(repo.isBare(), true);
|
||||
});
|
||||
test('opens standart repository from working directory successfully',
|
||||
() {
|
||||
expect(repo, isA<Repository>());
|
||||
});
|
||||
|
||||
test('returns path to the repository', () {
|
||||
expect(
|
||||
repo.path(),
|
||||
'${Directory.current.path}/test/assets/empty_bare.git/',
|
||||
);
|
||||
});
|
||||
test('returns path to the repository', () {
|
||||
expect(
|
||||
repo.path,
|
||||
'${Directory.current.path}/test/assets/empty_standard/.gitdir/',
|
||||
);
|
||||
});
|
||||
|
||||
test('returns path to root directory for the repository', () {
|
||||
expect(
|
||||
repo.commonDir(),
|
||||
'${Directory.current.path}/test/assets/empty_bare.git/',
|
||||
);
|
||||
});
|
||||
test('returns path to parent repo\'s .git folder for the repository',
|
||||
() {
|
||||
expect(
|
||||
repo.commonDir,
|
||||
'${Directory.current.path}/test/assets/empty_standard/.gitdir/',
|
||||
);
|
||||
});
|
||||
|
||||
test('returns empty string as path of the working directory', () {
|
||||
expect(repo.workdir(), '');
|
||||
test('checks if it is empty', () {
|
||||
expect(repo.isEmpty, true);
|
||||
});
|
||||
|
||||
test('checks if head is detached', () {
|
||||
expect(repo.isHeadDetached, false);
|
||||
});
|
||||
|
||||
test('checks if branch is unborn', () {
|
||||
expect(repo.isBranchUnborn, true);
|
||||
});
|
||||
|
||||
test('successfully sets identity ', () {
|
||||
repo.setIdentity(name: 'name', email: 'email@email.com');
|
||||
expect(repo.identity, {'name': 'email@email.com'});
|
||||
});
|
||||
|
||||
test('successfully unsets identity', () {
|
||||
repo.setIdentity(name: null, email: null);
|
||||
expect(repo.identity, isEmpty);
|
||||
});
|
||||
|
||||
test('checks if shallow clone', () {
|
||||
expect(repo.isShallow, false);
|
||||
});
|
||||
|
||||
test('checks if linked work tree', () {
|
||||
expect(repo.isWorktree, false);
|
||||
});
|
||||
|
||||
test('returns path to working directory', () {
|
||||
expect(
|
||||
repo.workdir,
|
||||
'${Directory.current.path}/test/assets/empty_standard/',
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
group('standard', () {
|
||||
setUp(() {
|
||||
repo = Repository.open('test/assets/empty_standard/.gitdir/');
|
||||
group('testrepo', () {
|
||||
final tmpDir = '${Directory.systemTemp.path}/testrepo/';
|
||||
|
||||
setUpAll(() async {
|
||||
await copyRepo(
|
||||
from: Directory('test/assets/testrepo/'),
|
||||
to: await Directory(tmpDir).create(),
|
||||
);
|
||||
repo = Repository.open(tmpDir);
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
tearDownAll(() async {
|
||||
repo.close();
|
||||
});
|
||||
|
||||
test('opens standart repository from working directory successfully', () {
|
||||
expect(repo, isA<Repository>());
|
||||
});
|
||||
|
||||
test('returns path to the repository', () {
|
||||
expect(
|
||||
repo.path(),
|
||||
'${Directory.current.path}/test/assets/empty_standard/.gitdir/',
|
||||
);
|
||||
});
|
||||
|
||||
test('returns path to parent repo\'s .git folder for the repository', () {
|
||||
expect(
|
||||
repo.commonDir(),
|
||||
'${Directory.current.path}/test/assets/empty_standard/.gitdir/',
|
||||
);
|
||||
});
|
||||
|
||||
test('checks if it is empty', () {
|
||||
expect(repo.isEmpty(), true);
|
||||
await Directory(tmpDir).delete(recursive: true);
|
||||
});
|
||||
|
||||
test('returns empty string when there is no namespace', () {
|
||||
expect(repo.getNamespace(), isEmpty);
|
||||
expect(repo.namespace, isEmpty);
|
||||
});
|
||||
|
||||
test('successfully sets and unsets the namespace', () {
|
||||
expect(repo.getNamespace(), '');
|
||||
expect(repo.namespace, '');
|
||||
repo.setNamespace('some');
|
||||
expect(repo.getNamespace(), 'some');
|
||||
expect(repo.namespace, 'some');
|
||||
repo.setNamespace(null);
|
||||
expect(repo.getNamespace(), '');
|
||||
});
|
||||
|
||||
test('checks if head is detached', () {
|
||||
expect(repo.isHeadDetached(), false);
|
||||
});
|
||||
|
||||
test('checks if branch is unborn', () {
|
||||
expect(repo.isBranchUnborn(), true);
|
||||
});
|
||||
|
||||
test('successfully sets identity ', () {
|
||||
repo.setIdentity(name: 'name', email: 'email@email.com');
|
||||
expect(repo.identity(), {'name': 'email@email.com'});
|
||||
});
|
||||
|
||||
test('successfully unsets identity', () {
|
||||
repo.setIdentity(name: null, email: null);
|
||||
expect(repo.identity(), isEmpty);
|
||||
});
|
||||
|
||||
test('checks if shallow clone', () {
|
||||
expect(repo.isShallow(), false);
|
||||
});
|
||||
|
||||
test('checks if linked work tree', () {
|
||||
expect(repo.isWorktree(), false);
|
||||
});
|
||||
|
||||
test('returns path to working directory', () {
|
||||
expect(
|
||||
repo.workdir(),
|
||||
'${Directory.current.path}/test/assets/empty_standard/',
|
||||
);
|
||||
expect(repo.namespace, '');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue