mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-04 20:29:08 -04:00
test: fix tests failing on windows
This commit is contained in:
parent
88455292d4
commit
90a6e59b2e
1 changed files with 36 additions and 8 deletions
|
@ -5,15 +5,15 @@ import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
final cloneDir = Directory(
|
// final cloneDir = Directory(
|
||||||
p.join(Directory.systemTemp.path, 'credentials_cloned'),
|
// p.join(Directory.systemTemp.path, 'credentials_cloned'),
|
||||||
);
|
// );
|
||||||
|
|
||||||
setUp(() {
|
// setUp(() {
|
||||||
if (cloneDir.existsSync()) {
|
// if (cloneDir.existsSync()) {
|
||||||
cloneDir.deleteSync(recursive: true);
|
// cloneDir.deleteSync(recursive: true);
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
|
||||||
group('Credentials', () {
|
group('Credentials', () {
|
||||||
test('initializes username/password credentials', () {
|
test('initializes username/password credentials', () {
|
||||||
|
@ -73,6 +73,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when provided username and password are incorrect', () {
|
test('throws when provided username and password are incorrect', () {
|
||||||
|
final cloneDir = Directory.systemTemp.createTempSync('clone');
|
||||||
final callbacks = const Callbacks(
|
final callbacks = const Callbacks(
|
||||||
credentials: UserPass(
|
credentials: UserPass(
|
||||||
username: 'libgit2',
|
username: 'libgit2',
|
||||||
|
@ -88,11 +89,14 @@ void main() {
|
||||||
),
|
),
|
||||||
throwsA(isA<LibGit2Error>()),
|
throwsA(isA<LibGit2Error>()),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
cloneDir.deleteSync(recursive: true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test(
|
test(
|
||||||
'clones repository with provided keypair',
|
'clones repository with provided keypair',
|
||||||
() {
|
() {
|
||||||
|
final cloneDir = Directory.systemTemp.createTempSync('clone');
|
||||||
final keypair = Keypair(
|
final keypair = Keypair(
|
||||||
username: 'git',
|
username: 'git',
|
||||||
pubKey: p.join('test', 'assets', 'keys', 'id_rsa.pub'),
|
pubKey: p.join('test', 'assets', 'keys', 'id_rsa.pub'),
|
||||||
|
@ -108,11 +112,15 @@ void main() {
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(repo.isEmpty, false);
|
expect(repo.isEmpty, false);
|
||||||
|
|
||||||
|
cloneDir.deleteSync(recursive: true);
|
||||||
},
|
},
|
||||||
testOn: '!linux',
|
testOn: '!linux',
|
||||||
);
|
);
|
||||||
|
|
||||||
test('throws when no credentials is provided', () {
|
test('throws when no credentials is provided', () {
|
||||||
|
final cloneDir = Directory.systemTemp.createTempSync('clone');
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
() => Repository.clone(
|
() => Repository.clone(
|
||||||
url: 'ssh://git@github.com/libgit2/TestGitRepository',
|
url: 'ssh://git@github.com/libgit2/TestGitRepository',
|
||||||
|
@ -120,9 +128,12 @@ void main() {
|
||||||
),
|
),
|
||||||
throwsA(isA<LibGit2Error>()),
|
throwsA(isA<LibGit2Error>()),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
cloneDir.deleteSync(recursive: true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when provided keypair is invalid', () {
|
test('throws when provided keypair is invalid', () {
|
||||||
|
final cloneDir = Directory.systemTemp.createTempSync('clone');
|
||||||
final keypair = const Keypair(
|
final keypair = const Keypair(
|
||||||
username: 'git',
|
username: 'git',
|
||||||
pubKey: 'invalid.pub',
|
pubKey: 'invalid.pub',
|
||||||
|
@ -139,9 +150,12 @@ void main() {
|
||||||
),
|
),
|
||||||
throwsA(isA<LibGit2Error>()),
|
throwsA(isA<LibGit2Error>()),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
cloneDir.deleteSync(recursive: true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when provided keypair is incorrect', () {
|
test('throws when provided keypair is incorrect', () {
|
||||||
|
final cloneDir = Directory.systemTemp.createTempSync('clone');
|
||||||
final keypair = Keypair(
|
final keypair = Keypair(
|
||||||
username: 'git',
|
username: 'git',
|
||||||
pubKey: p.join('test', 'assets', 'keys', 'id_rsa.pub'),
|
pubKey: p.join('test', 'assets', 'keys', 'id_rsa.pub'),
|
||||||
|
@ -158,9 +172,12 @@ void main() {
|
||||||
),
|
),
|
||||||
throwsA(isA<LibGit2Error>()),
|
throwsA(isA<LibGit2Error>()),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
cloneDir.deleteSync(recursive: true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when provided credential type is invalid', () {
|
test('throws when provided credential type is invalid', () {
|
||||||
|
final cloneDir = Directory.systemTemp.createTempSync('clone');
|
||||||
final callbacks = const Callbacks(
|
final callbacks = const Callbacks(
|
||||||
credentials: UserPass(
|
credentials: UserPass(
|
||||||
username: 'libgit2',
|
username: 'libgit2',
|
||||||
|
@ -176,11 +193,14 @@ void main() {
|
||||||
),
|
),
|
||||||
throwsA(isA<LibGit2Error>()),
|
throwsA(isA<LibGit2Error>()),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
cloneDir.deleteSync(recursive: true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test(
|
test(
|
||||||
'clones repository with provided keypair from memory',
|
'clones repository with provided keypair from memory',
|
||||||
() {
|
() {
|
||||||
|
final cloneDir = Directory.systemTemp.createTempSync('clone');
|
||||||
final pubKey = File(p.join('test', 'assets', 'keys', 'id_rsa.pub'))
|
final pubKey = File(p.join('test', 'assets', 'keys', 'id_rsa.pub'))
|
||||||
.readAsStringSync();
|
.readAsStringSync();
|
||||||
final privateKey =
|
final privateKey =
|
||||||
|
@ -200,11 +220,14 @@ void main() {
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(repo.isEmpty, false);
|
expect(repo.isEmpty, false);
|
||||||
|
|
||||||
|
cloneDir.deleteSync(recursive: true);
|
||||||
},
|
},
|
||||||
testOn: '!linux',
|
testOn: '!linux',
|
||||||
);
|
);
|
||||||
|
|
||||||
test('throws when provided keypair from memory is incorrect', () {
|
test('throws when provided keypair from memory is incorrect', () {
|
||||||
|
final cloneDir = Directory.systemTemp.createTempSync('clone');
|
||||||
final pubKey = File(p.join('test', 'assets', 'keys', 'id_rsa.pub'))
|
final pubKey = File(p.join('test', 'assets', 'keys', 'id_rsa.pub'))
|
||||||
.readAsStringSync();
|
.readAsStringSync();
|
||||||
final keypair = KeypairFromMemory(
|
final keypair = KeypairFromMemory(
|
||||||
|
@ -223,9 +246,12 @@ void main() {
|
||||||
),
|
),
|
||||||
throwsA(isA<LibGit2Error>()),
|
throwsA(isA<LibGit2Error>()),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
cloneDir.deleteSync(recursive: true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when provided keypair from agent is incorrect', () {
|
test('throws when provided keypair from agent is incorrect', () {
|
||||||
|
final cloneDir = Directory.systemTemp.createTempSync('clone');
|
||||||
final callbacks = const Callbacks(credentials: KeypairFromAgent('git'));
|
final callbacks = const Callbacks(credentials: KeypairFromAgent('git'));
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
|
@ -236,6 +262,8 @@ void main() {
|
||||||
),
|
),
|
||||||
throwsA(isA<LibGit2Error>()),
|
throwsA(isA<LibGit2Error>()),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
cloneDir.deleteSync(recursive: true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue