-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathnoTracking.nut.ts
More file actions
64 lines (57 loc) · 2.06 KB
/
noTracking.nut.ts
File metadata and controls
64 lines (57 loc) · 2.06 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
/*
* Copyright (c) 2023, 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 * as fs from 'node:fs';
import { join } from 'node:path';
import { execCmd, TestSession } from '@salesforce/cli-plugins-testkit';
import { assert, expect } from 'chai';
import { RetrieveResultJson } from '../../../src/utils/types.js';
const packageXml = `<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>*</members>
<name>ConnectedApp</name>
</types>
<version>56.0</version>
</Package>
`;
describe('retrieve mdapi format without project', () => {
const packageFile = 'package.xml';
let xmlPath: string | undefined;
let session: TestSession;
before(async () => {
session = await TestSession.create({
project: {
name: 'hasProjectNoTracking',
},
devhubAuthStrategy: 'AUTO',
});
assert(session.hubOrg.username);
xmlPath = join(session.project.dir, packageFile);
await fs.promises.writeFile(xmlPath, packageXml);
});
it('can retrieve using a project with a non-tracking org', () => {
const outputDir = 'mdapiOut';
const result = execCmd<RetrieveResultJson>(
`project:retrieve:start -o ${session.hubOrg.username} --target-metadata-dir ${outputDir} -x ${xmlPath} --json`,
{
ensureExitCode: 0,
}
).jsonOutput?.result;
// hub should have a connected app but not have tracking on
expect(result?.files).to.not.be.empty;
});
it('should fail when retrieving changes from a non-tracking org', () => {
const result = execCmd<RetrieveResultJson>(`project:retrieve:start -o ${session.hubOrg.username} --json`, {
ensureExitCode: 1,
});
expect(result.jsonOutput?.name).to.equal('noSourceTracking');
expect(result.jsonOutput?.message).to.include('Unable to track changes in your source files');
});
after(async () => {
await session?.clean();
});
});