mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-04 20:29:08 -04:00
refactor: extract repo setup for tests
This commit is contained in:
parent
10b9864219
commit
466f960c7b
26 changed files with 176 additions and 320 deletions
|
@ -5,18 +5,12 @@ import 'helpers/util.dart';
|
|||
|
||||
void main() {
|
||||
late Repository repo;
|
||||
late Directory tmpDir;
|
||||
late Signature stasher;
|
||||
final tmpDir = '${Directory.systemTemp.path}/stash_testrepo/';
|
||||
|
||||
setUp(() async {
|
||||
if (await Directory(tmpDir).exists()) {
|
||||
await Directory(tmpDir).delete(recursive: true);
|
||||
}
|
||||
await copyRepo(
|
||||
from: Directory('test/assets/testrepo/'),
|
||||
to: await Directory(tmpDir).create(),
|
||||
);
|
||||
repo = Repository.open(tmpDir);
|
||||
tmpDir = await setupRepo(Directory('test/assets/testrepo/'));
|
||||
repo = Repository.open(tmpDir.path);
|
||||
stasher = Signature.create(
|
||||
name: 'Stasher',
|
||||
email: 'stasher@email.com',
|
||||
|
@ -26,12 +20,12 @@ void main() {
|
|||
tearDown(() async {
|
||||
stasher.free();
|
||||
repo.free();
|
||||
await Directory(tmpDir).delete(recursive: true);
|
||||
await tmpDir.delete(recursive: true);
|
||||
});
|
||||
|
||||
group('Stash', () {
|
||||
test('successfully saves changes to stash', () {
|
||||
File('${tmpDir}file').writeAsStringSync(
|
||||
File('${tmpDir.path}/file').writeAsStringSync(
|
||||
'edit',
|
||||
mode: FileMode.append,
|
||||
);
|
||||
|
@ -41,7 +35,7 @@ void main() {
|
|||
});
|
||||
|
||||
test('successfully applies changes from stash', () {
|
||||
File('${tmpDir}file').writeAsStringSync(
|
||||
File('${tmpDir.path}/file').writeAsStringSync(
|
||||
'edit',
|
||||
mode: FileMode.append,
|
||||
);
|
||||
|
@ -54,7 +48,7 @@ void main() {
|
|||
});
|
||||
|
||||
test('successfully drops stash', () {
|
||||
File('${tmpDir}file').writeAsStringSync(
|
||||
File('${tmpDir.path}/file').writeAsStringSync(
|
||||
'edit',
|
||||
mode: FileMode.append,
|
||||
);
|
||||
|
@ -66,7 +60,7 @@ void main() {
|
|||
});
|
||||
|
||||
test('successfully pops from stash', () {
|
||||
File('${tmpDir}file').writeAsStringSync(
|
||||
File('${tmpDir.path}/file').writeAsStringSync(
|
||||
'edit',
|
||||
mode: FileMode.append,
|
||||
);
|
||||
|
@ -78,7 +72,7 @@ void main() {
|
|||
});
|
||||
|
||||
test('returns list of stashes', () {
|
||||
File('${tmpDir}file').writeAsStringSync(
|
||||
File('${tmpDir.path}/file').writeAsStringSync(
|
||||
'edit',
|
||||
mode: FileMode.append,
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue