Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/platform/agentHost/test/node/gitDiffContent.test.ts
13399 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import assert from 'assert';
7
import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../base/test/common/utils.js';
8
import { buildGitBlobUri, parseGitBlobUri } from '../../node/gitDiffContent.js';
9
10
suite('gitDiffContent', () => {
11
ensureNoDisposablesAreLeakedInTestSuite();
12
13
test('round-trips simple inputs', () => {
14
const sessionUri = 'copilot:/abc-123';
15
const sha = 'deadbeef0123456789abcdef0123456789abcdef';
16
const path = 'src/foo/bar.ts';
17
const built = buildGitBlobUri(sessionUri, sha, path);
18
const parsed = parseGitBlobUri(built);
19
assert.deepStrictEqual(parsed, { sessionUri, sha, repoRelativePath: path });
20
});
21
22
test('round-trips paths with spaces, unicode and slashes', () => {
23
const sessionUri = 'copilot:/sess/with space?q=1';
24
const sha = '1234567890abcdef1234567890abcdef12345678';
25
const path = 'a folder/файл.txt';
26
const parsed = parseGitBlobUri(buildGitBlobUri(sessionUri, sha, path));
27
assert.deepStrictEqual(parsed, { sessionUri, sha, repoRelativePath: path });
28
});
29
30
test('returns undefined for non git-blob URIs', () => {
31
assert.strictEqual(parseGitBlobUri('file:///foo/bar.ts'), undefined);
32
assert.strictEqual(parseGitBlobUri('session-db://abc/def/before/x'), undefined);
33
assert.strictEqual(parseGitBlobUri('not a uri at all'), undefined);
34
});
35
});
36
37