Skip to content

Commit d562ebb

Browse files
committed
ref microsoft#44776 Wrote a test for Repository#getCommit
1 parent cfb26b3 commit d562ebb

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

extensions/git/src/test/git.test.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
'use strict';
77

88
import 'mocha';
9-
import { GitStatusParser, parseGitmodules } from '../git';
9+
import { Git, GitStatusParser, Repository, parseGitmodules } from '../git';
1010
import * as assert from 'assert';
11+
import * as sinon from 'sinon';
1112

1213
suite('git', () => {
1314
suite('GitStatusParser', () => {
@@ -175,4 +176,22 @@ suite('git', () => {
175176
]);
176177
});
177178
});
179+
180+
suite('Repository', () => {
181+
test('get commit', async () => {
182+
const spawnOption = {};
183+
const gitOutput = `52c293a05038d865604c2284aa8698bd087915a1
184+
This is a commit message.`;
185+
const git = sinon.createStubInstance(Git);
186+
git.exec = sinon.stub()
187+
.withArgs('REPOSITORY_ROOT', ['show', '-s', '--format=%H\n%B', 'REF'], spawnOption)
188+
.returns(Promise.resolve({stdout: gitOutput}));
189+
const repository = new Repository(git, 'REPOSITORY_ROOT');
190+
191+
assert.deepEqual(await repository.getCommit('REF'), {
192+
hash: '52c293a05038d865604c2284aa8698bd087915a1',
193+
message: 'This is a commit message.'
194+
});
195+
});
196+
});
178197
});

0 commit comments

Comments
 (0)