-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathpackageVersionRetrieve.test.ts
More file actions
75 lines (68 loc) · 2.39 KB
/
Copy pathpackageVersionRetrieve.test.ts
File metadata and controls
75 lines (68 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
* Copyright (c) 2020, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import { join } from 'node:path';
import { MockTestOrgData, TestContext } from '@salesforce/core/testSetup';
import { Config } from '@oclif/core';
import { expect } from 'chai';
import { SourceComponent, registry } from '@salesforce/source-deploy-retrieve';
import { Package, PackageVersionMetadataDownloadResult } from '@salesforce/packaging';
import { PackageVersionRetrieveCommand } from '../../../src/commands/package/version/retrieve.js';
const myPackageVersion04t = '04t000000000001';
const pkgVersionRetrieveSuccessResult: PackageVersionMetadataDownloadResult = {
packagePath: '/tmp/foo',
converted: [
new SourceComponent({
name: 'ComponentA',
type: registry.types['apexclass'],
xml: join('nonexistentDir', 'ComponentA.cls-meta.xml'),
content: join('nonexistentDir', 'ComponentA.cls'),
}),
new SourceComponent({
name: 'ComponentB',
type: registry.types['customobject'],
content: join('nonexistentDir', 'ComponentB.object-meta.xml'),
}),
],
};
const expectedRetrievedComponents = [
{
filePath: join('nonexistentDir', 'ComponentA.cls-meta.xml'),
fullName: 'ComponentA',
type: 'ApexClass',
},
{
filePath: join('nonexistentDir', 'ComponentA.cls'),
fullName: 'ComponentA',
type: 'ApexClass',
},
{
filePath: join('nonexistentDir', 'ComponentB.object-meta.xml'),
fullName: 'ComponentB',
type: 'CustomObject',
},
];
describe('package:version:retrieve - tests', () => {
const $$ = new TestContext();
const testOrg = new MockTestOrgData();
const downloadStub = $$.SANDBOX.stub(Package, 'downloadPackageVersionMetadata');
const config = new Config({ root: import.meta.url });
before(async () => {
await $$.stubAuths(testOrg);
await config.load();
});
afterEach(() => {
$$.restore();
});
describe('package:version:retrieve', () => {
it('should display retrieved files', async () => {
downloadStub.resolves(pkgVersionRetrieveSuccessResult);
const cmd = new PackageVersionRetrieveCommand(['-p', myPackageVersion04t, '-v', 'test@dev.org'], config);
const res = await cmd.run();
expect(res).to.deep.equal(expectedRetrievedComponents);
});
});
});