Skip to content

Commit

Permalink
fix: check for resumable state for sandbox resume
Browse files Browse the repository at this point in the history
@W-12467406@
  • Loading branch information
peternhale committed Feb 28, 2023
1 parent 4bd8fe5 commit 157622f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
4 changes: 4 additions & 0 deletions messages/org.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,7 @@ We can't find a SandboxProcess with the SandboxName %s.
# MultiSandboxProcessNotFoundBySandboxName

We found more than one SandboxProcess with the SandboxName %s.

# sandboxNotResumable

The sandbox %s cannot resume with status of %s.
29 changes: 13 additions & 16 deletions src/org/org.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,7 @@ import { scratchOrgCreate, ScratchOrgCreateOptions, ScratchOrgCreateResult } fro
import { OrgConfigProperties } from './orgConfigProperties';

Messages.importMessagesDirectory(__dirname);
const messages = Messages.load('@salesforce/core', 'org', [
'deleteOrgHubError',
'insufficientAccessToDelete',
'missingAuthUsername',
'noDevHubFound',
'notADevHub',
'noUsernameFound',
'sandboxDeleteFailed',
'sandboxInfoCreateFailed',
'sandboxNotFound',
'scratchOrgNotFound',
'AuthInfoOrgIdUndefined',
'sandboxCreateNotComplete',
'SandboxProcessNotFoundBySandboxName',
'MultiSandboxProcessNotFoundBySandboxName',
]);
const messages = Messages.loadMessages('@salesforce/core', 'org');

export type OrganizationInformation = {
Name: string;
Expand Down Expand Up @@ -107,6 +92,12 @@ export interface SandboxUserAuthResponse {
loginUrl: string;
}

const resumableSandboxStatus = ['Activating', 'Pending', 'Pending Activation', 'Processing', 'Sampling'];

export function sandboxIsResumable(value: string): boolean {
return resumableSandboxStatus.includes(value);
}

export type SandboxProcessObject = {
Id: string;
Status: string;
Expand Down Expand Up @@ -315,6 +306,12 @@ export class Org extends AsyncOptionalCreatable<Org.Options> {
throw messages.createError('sandboxCreateNotComplete');
}

if (!sandboxIsResumable(sandboxCreationProgress.Status)) {
throw messages.createError('sandboxNotResumable', [
sandboxCreationProgress.SandboxName,
sandboxCreationProgress.Status,
]);
}
this.logger.debug(
`resume - pollStatusAndAuth sandboxProcessObj ${JSON.stringify(
sandboxCreationProgress,
Expand Down

0 comments on commit 157622f

Please sign in to comment.