mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-05 04:39:07 -04:00
feat(stash): add bindings and api
This commit is contained in:
parent
7b8dfcc1af
commit
3cb55817ad
7 changed files with 386 additions and 13 deletions
|
@ -374,6 +374,74 @@ void main() {
|
|||
throwsA(isA<LibGit2Error>()),
|
||||
);
|
||||
});
|
||||
|
||||
group('stash', () {
|
||||
late Signature stasher;
|
||||
setUp(() {
|
||||
stasher = Signature.create(
|
||||
name: 'Stasher',
|
||||
email: 'stasher@email.com',
|
||||
);
|
||||
});
|
||||
|
||||
tearDown(() => stasher.free());
|
||||
|
||||
test('successfully saves changes to stash', () {
|
||||
File('${tmpDir}file').writeAsStringSync(
|
||||
'edit',
|
||||
mode: FileMode.append,
|
||||
);
|
||||
|
||||
repo.stash(stasher: stasher, includeUntracked: true);
|
||||
expect(repo.status.isEmpty, true);
|
||||
});
|
||||
|
||||
test('successfully applies changes from stash', () {
|
||||
File('${tmpDir}file').writeAsStringSync(
|
||||
'edit',
|
||||
mode: FileMode.append,
|
||||
);
|
||||
|
||||
repo.stash(stasher: stasher);
|
||||
expect(repo.status.isEmpty, true);
|
||||
|
||||
repo.stashApply();
|
||||
expect(repo.status, contains('file'));
|
||||
});
|
||||
|
||||
test('successfully drops stash', () {
|
||||
File('${tmpDir}file').writeAsStringSync(
|
||||
'edit',
|
||||
mode: FileMode.append,
|
||||
);
|
||||
|
||||
repo.stash(stasher: stasher);
|
||||
repo.stashDrop();
|
||||
expect(() => repo.stashApply(), throwsA(isA<LibGit2Error>()));
|
||||
});
|
||||
|
||||
test('successfully pops from stash', () {
|
||||
File('${tmpDir}file').writeAsStringSync(
|
||||
'edit',
|
||||
mode: FileMode.append,
|
||||
);
|
||||
|
||||
repo.stash(stasher: stasher);
|
||||
repo.stashPop();
|
||||
expect(repo.status, contains('file'));
|
||||
expect(() => repo.stashApply(), throwsA(isA<LibGit2Error>()));
|
||||
});
|
||||
|
||||
test('returns list of stashes', () {
|
||||
File('${tmpDir}file').writeAsStringSync(
|
||||
'edit',
|
||||
mode: FileMode.append,
|
||||
);
|
||||
|
||||
repo.stash(stasher: stasher);
|
||||
expect(repo.stashList.length, 1);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue