test: fix tests failing on windows

This commit is contained in:
Aleksey Kulikov 2021-10-29 10:59:30 +03:00 committed by GitHub
parent f4e17b124d
commit a71bb14b86
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 26 additions and 34 deletions

View file

@ -39,6 +39,11 @@ jobs:
runs-on: ${{ matrix.platform }}
steps:
- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@v2
- uses: dart-lang/setup-dart@v1
with:
@ -52,4 +57,3 @@ jobs:
- name: Run tests
run: dart test --exclude-tags "remote_fetch" --platform vm
if: matrix.platform != 'windows-latest'

View file

@ -1,3 +1,4 @@
import 'dart:ffi';
import 'dart:io';
import 'package:libgit2dart/libgit2dart.dart';
@ -30,11 +31,7 @@ void main() {
});
test('throws when trying to get odb and error occurs', () {
Directory('${repo.workdir}.git/objects/').deleteSync(recursive: true);
expect(
() => repo.odb,
throwsA(isA<LibGit2Error>()),
);
expect(() => Repository((nullptr)).odb, throwsA(isA<LibGit2Error>()));
});
test('successfully creates new odb with no backends', () {

View file

@ -122,7 +122,7 @@ void main() {
expect(clonedRepo.isEmpty, false);
expect(clonedRepo.isBare, false);
expect(clonedRepo.path, contains('${callbackPath.path}/.git/'));
expect(clonedRepo.path, contains('/callbackRepo/.git/'));
clonedRepo.free();
callbackPath.deleteSync(recursive: true);

View file

@ -1,5 +1,4 @@
import 'dart:ffi';
import 'dart:io';
import 'package:libgit2dart/libgit2dart.dart';
import 'package:test/test.dart';
@ -10,7 +9,7 @@ void main() {
group('Repository.open', () {
test("throws when repository isn't found at provided path", () {
expect(
() => Repository.open(''),
() => Repository.open('/not/there'),
throwsA(isA<LibGit2Error>()),
);
});
@ -33,17 +32,11 @@ void main() {
});
test('returns path to the repository', () {
expect(
repo.path,
'${Directory.current.path}/test/assets/empty_bare.git/',
);
expect(repo.path, contains('/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/',
);
expect(repo.commonDir, contains('/test/assets/empty_bare.git/'));
});
test('returns empty string as path of the working directory', () {
@ -65,16 +58,13 @@ void main() {
});
test('returns path to the repository', () {
expect(
repo.path,
'${Directory.current.path}/test/assets/empty_standard/.gitdir/',
);
expect(repo.path, contains('/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/',
contains('/test/assets/empty_standard/.gitdir/'),
);
});
@ -113,10 +103,7 @@ void main() {
});
test('returns path to working directory', () {
expect(
repo.workdir,
'${Directory.current.path}/test/assets/empty_standard/',
);
expect(repo.workdir, contains('/test/assets/empty_standard/'));
});
});
});

View file

@ -23,14 +23,14 @@ void main() {
test('successfully creates new bare repo at provided path', () {
repo = Repository.init(path: initDir.path, bare: true);
expect(repo.path, contains('${initDir.path}/'));
expect(repo.path, contains('init_repo/'));
expect(repo.isBare, true);
});
test('successfully creates new standard repo at provided path', () {
repo = Repository.init(path: initDir.path);
expect(repo.path, contains('${initDir.path}/.git/'));
expect(repo.path, contains('init_repo/.git/'));
expect(repo.isBare, false);
expect(repo.isEmpty, true);
});
@ -43,11 +43,11 @@ void main() {
flags: {GitRepositoryInit.mkdir, GitRepositoryInit.mkpath},
);
expect(repo.path, contains('${initDir.path}/.git/'));
expect(repo.path, contains('init_repo/.git/'));
expect(repo.isBare, false);
expect(repo.isEmpty, true);
expect(
File('${initDir.path}/.git/description').readAsStringSync(),
File('${repo.workdir}.git/description').readAsStringSync(),
'test repo',
);
expect(repo.lookupRemote('origin').url, 'test.url');

View file

@ -91,7 +91,7 @@ void main() {
tmpWorkDir.createSync();
repo.setWorkdir(path: tmpWorkDir.path);
expect(repo.workdir, contains('${tmpWorkDir.path}/'));
expect(repo.workdir, contains('/tmp_work_dir/'));
tmpWorkDir.deleteSync();
});

View file

@ -20,7 +20,11 @@ void main() {
tearDown(() {
repo.free();
try {
tmpDir.deleteSync(recursive: true);
} catch (e) {
return;
}
});
group('Submodule', () {

View file

@ -41,7 +41,7 @@ void main() {
expect(repo.worktrees, [worktreeName]);
expect(branches.any((branch) => branch.name == worktreeName), true);
expect(worktree.name, worktreeName);
expect(worktree.path, contains(worktreeDir.path));
expect(worktree.path, contains('/worktree'));
expect(worktree.isLocked, false);
expect(worktree.toString(), contains('Worktree{'));
expect(File('${worktreeDir.path}/.git').existsSync(), true);
@ -113,7 +113,7 @@ void main() {
final lookedupWorktree = repo.lookupWorktree(worktreeName);
expect(lookedupWorktree.name, worktreeName);
expect(lookedupWorktree.path, contains(worktreeDir.path));
expect(lookedupWorktree.path, contains('/worktree'));
expect(lookedupWorktree.isLocked, false);
lookedupWorktree.free();