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.
- Loading branch information
1 parent
a57409a
commit 50d03b6
Showing
3 changed files
with
135 additions
and
0 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,27 @@ | ||
/* | ||
* 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 { execCmd, TestSession } from '@salesforce/cli-plugins-testkit'; | ||
import { expect } from 'chai'; | ||
|
||
describe('data update bulk NUTs', () => { | ||
let session: TestSession; | ||
|
||
before(async () => { | ||
session = await TestSession.create({ devhubAuthStrategy: 'NONE' }); | ||
}); | ||
|
||
after(async () => { | ||
await session?.clean(); | ||
}); | ||
|
||
it('should display provided name', () => { | ||
const name = 'World'; | ||
const command = `data update bulk --name ${name}`; | ||
const output = execCmd(command, { ensureExitCode: 0 }).shellOutput.stdout; | ||
expect(output).to.contain(name); | ||
}); | ||
}); |
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) 2024, 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 { execCmd, TestSession } from '@salesforce/cli-plugins-testkit'; | ||
import { expect } from 'chai'; | ||
import { Org } from '@salesforce/core'; | ||
import { generateUpdatedCsv } from 'test/testUtil.js'; | ||
import { generateAccountsCsv } from '../import/resume.nut.js'; | ||
import { DataUpdateBulkResult } from '../../../../src/commands/data/update/bulk.js'; | ||
import { DataImportBulkResult } from '../../../../src/commands/data/import/bulk.js'; | ||
|
||
describe('data update resume NUTs', () => { | ||
let session: TestSession; | ||
|
||
before(async () => { | ||
session = await TestSession.create({ | ||
scratchOrgs: [ | ||
{ | ||
config: 'config/project-scratch-def.json', | ||
setDefault: true, | ||
}, | ||
], | ||
project: { sourceDir: path.join('test', 'test-files', 'data-project') }, | ||
devhubAuthStrategy: 'AUTO', | ||
}); | ||
}); | ||
|
||
after(async () => { | ||
await session?.clean(); | ||
}); | ||
|
||
it.only('should update account records', async () => { | ||
const csvFile = await generateAccountsCsv(session.dir); | ||
|
||
const result = execCmd<DataImportBulkResult>( | ||
`data import bulk --file ${csvFile} --sobject Account --wait 10 --json`, | ||
{ ensureExitCode: 0 } | ||
).jsonOutput?.result as DataImportBulkResult; | ||
|
||
// TODO: set org username above like here: | ||
// https://github.com/salesforcecli/cli-plugins-testkit/blob/main/SAMPLES.md#testing-with-multiple-scratch-orgs | ||
const username = [...session.orgs.keys()][0]; | ||
|
||
const conn = ( | ||
await Org.create({ | ||
aliasOrUsername: username, | ||
}) | ||
).getConnection(); | ||
|
||
const importJob = conn.bulk2.job('ingest', { | ||
id: result.jobId, | ||
}); | ||
|
||
const successfulIds = (await importJob.getSuccessfulResults()).map((r) => r.sf__Id); | ||
|
||
const updatedCsv = await generateUpdatedCsv(csvFile, successfulIds); | ||
|
||
const dataUpdateResult = execCmd<DataUpdateBulkResult>( | ||
`data update bulk --file ${updatedCsv}--sobject account --wait 10` | ||
).jsonOutput?.result as DataUpdateBulkResult; | ||
|
||
expect(dataUpdateResult.processedRecords).to.equal(10_000); | ||
expect(dataUpdateResult.successfulRecords).to.equal(10_000); | ||
expect(dataUpdateResult.failedRecords).to.equal(0); | ||
}); | ||
}); |
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