ref #44776 Wrote a test for Repository#getCommit

This commit is contained in:
Ryuichi Inagaki
2018-04-08 23:26:39 +10:00
parent cfb26b3d4b
commit d562ebbf25

View File

@@ -6,8 +6,9 @@
'use strict';
import 'mocha';
import { GitStatusParser, parseGitmodules } from '../git';
import { Git, GitStatusParser, Repository, parseGitmodules } from '../git';
import * as assert from 'assert';
import * as sinon from 'sinon';
suite('git', () => {
suite('GitStatusParser', () => {
@@ -175,4 +176,22 @@ suite('git', () => {
]);
});
});
suite('Repository', () => {
test('get commit', async () => {
const spawnOption = {};
const gitOutput = `52c293a05038d865604c2284aa8698bd087915a1
This is a commit message.`;
const git = sinon.createStubInstance(Git);
git.exec = sinon.stub()
.withArgs('REPOSITORY_ROOT', ['show', '-s', '--format=%H\n%B', 'REF'], spawnOption)
.returns(Promise.resolve({stdout: gitOutput}));
const repository = new Repository(git, 'REPOSITORY_ROOT');
assert.deepEqual(await repository.getCommit('REF'), {
hash: '52c293a05038d865604c2284aa8698bd087915a1',
message: 'This is a commit message.'
});
});
});
});