Files
azuredatastudio/src/vs/platform/extensionManagement/test/node/extensionGalleryService.test.ts
Anthony Dresser 87765e8673 Vscode merge (#4582)
* Merge from vscode 37cb23d3dd4f9433d56d4ba5ea3203580719a0bd

* fix issues with merges

* bump node version in azpipe

* replace license headers

* remove duplicate launch task

* fix build errors

* fix build errors

* fix tslint issues

* working through package and linux build issues

* more work

* wip

* fix packaged builds

* working through linux build errors

* wip

* wip

* wip

* fix mac and linux file limits

* iterate linux pipeline

* disable editor typing

* revert series to parallel

* remove optimize vscode from linux

* fix linting issues

* revert testing change

* add work round for new node

* readd packaging for extensions

* fix issue with angular not resolving decorator dependencies
2019-03-19 17:44:35 -07:00

93 lines
3.5 KiB
TypeScript

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import * as os from 'os';
import * as extfs from 'vs/base/node/extfs';
import { EnvironmentService } from 'vs/platform/environment/node/environmentService';
import { parseArgs } from 'vs/platform/environment/node/argv';
import { getRandomTestPath } from 'vs/base/test/node/testUtils';
import { join } from 'vs/base/common/path';
import { mkdirp } from 'vs/base/node/pfs';
// {{SQL CARBON EDIT}}
import { resolveMarketplaceHeaders, ExtensionGalleryService } from 'vs/platform/extensionManagement/node/extensionGalleryService';
import { isUUID } from 'vs/base/common/uuid';
suite('Extension Gallery Service', () => {
const parentDir = getRandomTestPath(os.tmpdir(), 'vsctests', 'extensiongalleryservice');
const marketplaceHome = join(parentDir, 'Marketplace');
setup(done => {
// Delete any existing backups completely and then re-create it.
extfs.del(marketplaceHome, os.tmpdir(), () => {
mkdirp(marketplaceHome).then(() => {
done();
}, error => done(error));
});
});
teardown(done => {
extfs.del(marketplaceHome, os.tmpdir(), done);
});
test('marketplace machine id', () => {
const args = ['--user-data-dir', marketplaceHome];
const environmentService = new EnvironmentService(parseArgs(args), process.execPath);
return resolveMarketplaceHeaders(environmentService).then(headers => {
assert.ok(isUUID(headers['X-Market-User-Id']));
return resolveMarketplaceHeaders(environmentService).then(headers2 => {
assert.equal(headers['X-Market-User-Id'], headers2['X-Market-User-Id']);
});
});
});
// {{SQL CARBON EDIT}}
test('sortByField', () => {
let a = {
extensionId: undefined,
extensionName: undefined,
displayName: undefined,
shortDescription: undefined,
publisher: undefined
};
let b = {
extensionId: undefined,
extensionName: undefined,
displayName: undefined,
shortDescription: undefined,
publisher: undefined
};
assert.equal(ExtensionGalleryService.compareByField(a.publisher, b.publisher, 'publisherName'), 0);
a.publisher = { displayName: undefined, publisherId: undefined, publisherName: undefined};
assert.equal(ExtensionGalleryService.compareByField(a.publisher, b.publisher, 'publisherName'), 1);
b.publisher = { displayName: undefined, publisherId: undefined, publisherName: undefined};
assert.equal(ExtensionGalleryService.compareByField(a.publisher, b.publisher, 'publisherName'), 0);
a.publisher.publisherName = 'a';
assert.equal(ExtensionGalleryService.compareByField(a.publisher, b.publisher, 'publisherName'), 1);
b.publisher.publisherName = 'b';
assert.equal(ExtensionGalleryService.compareByField(a.publisher, b.publisher, 'publisherName'), -1);
b.publisher.publisherName = 'a';
assert.equal(ExtensionGalleryService.compareByField(a.publisher, b.publisher, 'publisherName'), 0);
a.displayName = 'test1';
assert.equal(ExtensionGalleryService.compareByField(a, b, 'displayName'), 1);
b.displayName = 'test2';
assert.equal(ExtensionGalleryService.compareByField(a, b, 'displayName'), -1);
b.displayName = 'test1';
assert.equal(ExtensionGalleryService.compareByField(a, b, 'displayName'), 0);
});
});