generated from salesforcecli/lerna-template
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: prove that junction objects work for upload
- Loading branch information
Showing
2 changed files
with
70 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* 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 path from 'node:path'; | ||
import { expect } from 'chai'; | ||
import { execCmd, TestSession } from '@salesforce/cli-plugins-testkit'; | ||
import { ImportResult } from '../../../../src/api/data/tree/importTypes.js'; | ||
|
||
describe('data:tree commands', () => { | ||
let testSession: TestSession; | ||
|
||
before(async () => { | ||
testSession = await TestSession.create({ | ||
scratchOrgs: [ | ||
{ | ||
config: 'config/project-scratch-def.json', | ||
setDefault: true, | ||
}, | ||
{ | ||
config: 'config/project-scratch-def.json', | ||
setDefault: false, | ||
alias: 'importOrg', | ||
}, | ||
], | ||
project: { sourceDir: path.join('test', 'test-files', 'data-project') }, | ||
devhubAuthStrategy: 'AUTO', | ||
}); | ||
}); | ||
|
||
after(async () => { | ||
await testSession?.clean(); | ||
}); | ||
|
||
it('new tree can import junction objects', () => { | ||
const importResult = execCmd<ImportResult[]>( | ||
`data:import:beta:tree --plan ${path.join( | ||
'data', | ||
'junction', | ||
'Account-AccountContactRelation-Contact-plan.json' | ||
)} --json`, | ||
{ ensureExitCode: 0 } | ||
); | ||
expect(importResult.jsonOutput?.result.length).to.equal(12); | ||
}); | ||
|
||
it('import -> export -> import round trip should succeed', () => { | ||
const query = | ||
"select Id, Name, (Select Id, FirstName, LastName, (select AccountId, ContactId from AccountContactRoles) from Contacts), (select Id, ContactId, AccountId from AccountContactRelations where Account.Name != 'We Know Everybody') from Account where Name != 'Sample Account for Entitlements'"; | ||
|
||
execCmd(`data:export:beta:tree --query "${query}" --outputdir ${path.join('.', 'export_data')} --plan --json`, { | ||
ensureExitCode: 0, | ||
}); | ||
|
||
// Import data to the default org. | ||
const importResult = execCmd<ImportResult[]>( | ||
`data:import:beta:tree --target-org importOrg --plan ${path.join( | ||
'.', | ||
'export_data', | ||
'Account-AccountContactRelation-Contact-plan.json' | ||
)} --json`, | ||
{ | ||
ensureExitCode: 0, | ||
} | ||
); | ||
expect(importResult.jsonOutput?.result.length).to.equal(12); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters