From d67232a77d6f18a6e7f90c0879291a41eb630c0b Mon Sep 17 00:00:00 2001 From: mshanemc Date: Mon, 20 Mar 2023 17:19:00 -0500 Subject: [PATCH] feat: shorter scratch org lifetime --- src/testSession.ts | 15 ++++----------- test/unit/testSession.test.ts | 6 +++--- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/testSession.ts b/src/testSession.ts index 402337e2..2926316b 100644 --- a/src/testSession.ts +++ b/src/testSession.ts @@ -329,7 +329,10 @@ export class TestSession exte } let baseCmd = - executable === 'sf' ? `${executable} env create scratch --json` : `${executable} force:org:create --json`; + executable === 'sf' + ? `${executable} env create scratch --json -y ${org.duration ?? '1'}` + : `${executable} force:org:create --json -d ${org.duration ?? '1'}`; + baseCmd += ` -w ${org.wait ?? 60}`; if (org.config) { baseCmd += ` -f ${org.config}`; @@ -339,10 +342,6 @@ export class TestSession exte baseCmd += ` -a ${org.alias}`; } - if (org.duration) { - baseCmd += executable === 'sf' ? ` -y ${org.duration}` : ` -d ${org.duration}`; - } - if (org.setDefault) { baseCmd += executable === 'sf' ? ' -d' : ' -s'; } @@ -356,12 +355,6 @@ export class TestSession exte baseCmd += executable === 'sf' ? ` -e ${org.edition}` : ` edition=${org.edition}`; } - if (org.wait) { - baseCmd += ` -w ${org.wait}`; - } else { - baseCmd += ' -w 60'; - } - const rv = shell.exec(baseCmd, this.shelljsExecOptions) as shell.ShellString; rv.stdout = stripAnsi(rv.stdout); rv.stderr = stripAnsi(rv.stderr); diff --git a/test/unit/testSession.test.ts b/test/unit/testSession.test.ts index b75b8b62..c68ef651 100644 --- a/test/unit/testSession.test.ts +++ b/test/unit/testSession.test.ts @@ -180,7 +180,7 @@ describe('TestSession', () => { expect(execStub.callCount).to.equal(scratchOrgs.length * (retries + 1)); expect(session.orgs.get(username)).to.deep.equal({ username, orgId: '12345' }); expect(execStub.firstCall.args[0]).to.equal( - 'sf env create scratch --json -f config/project-scratch-def.json -w 60' + 'sf env create scratch --json -y 1 -w 60 -f config/project-scratch-def.json' ); }); @@ -215,7 +215,7 @@ describe('TestSession', () => { expect(session.orgs.get(username)).to.deep.equal({ username, orgId: '12345' }); expect(session.orgs.get('default')).to.deep.equal({ username, orgId: '12345' }); expect(execStub.firstCall.args[0]).to.equal( - 'sf env create scratch --json -f config/project-scratch-def.json -a my-org -y 1 -d -e developer -w 60' + 'sf env create scratch --json -y 1 -w 60 -f config/project-scratch-def.json -a my-org -d -e developer' ); expect(process.env.HOME).to.equal(session.homeDir); expect(process.env.USERPROFILE).to.equal(session.homeDir); @@ -256,7 +256,7 @@ describe('TestSession', () => { it('should error if setup command fails', async () => { stubMethod(sandbox, shelljs, 'which').returns(true); - const expectedCmd = 'sf env create scratch --json -f config/project-scratch-def.json -w 60'; + const expectedCmd = 'sf env create scratch --json -y 1 -w 60 -f config/project-scratch-def.json'; const execRv = 'Cannot foo before bar'; const shellString = new ShellString(JSON.stringify(execRv)); shellString.code = 1;