This repository has been archived by the owner on Jul 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
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
e7c2e45
commit 507fb91
Showing
1 changed file
with
20 additions
and
39 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 |
---|---|---|
|
@@ -10,16 +10,7 @@ import { command, Config, expect, FancyTypes } from '@oclif/test'; | |
import { Config as OclifConfig } from '@oclif/core'; | ||
import { AuthFields, SfProject } from '@salesforce/core'; | ||
import { TestContext, testSetup } from '@salesforce/core/lib/testSetup'; | ||
import { | ||
AnyJson, | ||
asJsonMap, | ||
definiteValuesOf, | ||
Dictionary, | ||
ensure, | ||
ensureString, | ||
JsonMap, | ||
Optional, | ||
} from '@salesforce/ts-types'; | ||
import { AnyJson, asJsonMap, definiteValuesOf, Dictionary, ensure, JsonMap, Optional } from '@salesforce/ts-types'; | ||
|
||
import { loadConfig } from '@oclif/test/lib/load-config'; | ||
import { SinonStub } from 'sinon'; | ||
|
@@ -44,44 +35,34 @@ const withOrg = (org: Partial<AuthFields> = {}, setAsDefault = true): Plugin<Dic | |
if (!org.username) { | ||
org.username = '[email protected]'; | ||
} | ||
ctx.orgs[org.username] = {}; | ||
|
||
// Override org if it exists on context | ||
ctx.orgs[org.username] = Object.assign( | ||
{ | ||
orgId: '0x012123', | ||
instanceUrl: 'http://na30.salesforce.com', | ||
loginUrl: 'https://login.salesforce.com', | ||
created: '1519163543003', | ||
isDevHub: false, | ||
}, | ||
org | ||
); | ||
|
||
ctx.orgs[org.username].default = setAsDefault; | ||
ctx.orgs[org.username].orgs = { | ||
[org.username]: Object.assign( | ||
{ | ||
orgId: '0x012123', | ||
instanceUrl: 'http://na30.salesforce.com', | ||
loginUrl: 'https://login.salesforce.com', | ||
created: '1519163543003', | ||
isDevHub: false, | ||
default: setAsDefault, | ||
}, | ||
org | ||
), | ||
}; | ||
|
||
// eslint-disable-next-line @typescript-eslint/require-await | ||
const readOrg = async function (this: { path: string }): Promise<JsonMap> { | ||
const path = this.path; | ||
return asJsonMap( | ||
find(ctx.orgs, (val) => { | ||
return path.includes(ensureString(val.username)); | ||
}), | ||
{} | ||
); | ||
return asJsonMap(ctx.orgs[org.username as string], {}); | ||
}; | ||
// eslint-disable-next-line @typescript-eslint/require-await | ||
const writeOrg = async function (this: { path: string }): Promise<JsonMap> { | ||
const path = this.path; | ||
const foundOrg = asJsonMap( | ||
find(ctx.orgs, (val) => { | ||
return path.includes(ensureString(val.username)); | ||
}), | ||
{} | ||
); | ||
return (ensure($$.configStubs.AuthInfoConfig).contents = foundOrg); | ||
const foundOrg = asJsonMap(ctx.orgs[org.username as string], {}); | ||
return (ensure($$.configStubs.GlobalInfo).contents = { orgs: { [org.username as string]: foundOrg } }); | ||
}; | ||
|
||
$$.configStubs.AuthInfoConfig = { | ||
$$.configStubs.GlobalInfo = { | ||
retrieveContents: readOrg, | ||
updateContents: writeOrg, | ||
}; | ||
|
@@ -129,7 +110,7 @@ const withProject = (SfProjectJson?: JsonMap): Plugin<unknown> => { | |
}; | ||
}; | ||
|
||
const test: typeof oclifTest.test = oclifTest.test | ||
const test = oclifTest.test | ||
.register('withOrg', withOrg) | ||
.register('withConnectionRequest', withConnectionRequest) | ||
.register('withProject', withProject); | ||
|