Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions services/cloud-agent-next/src/workspace-backup-cache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,8 @@ function bucketWith(value: unknown) {
}

describe('workspace backup cache policy', () => {
it.each([[undefined], [[]]])(
'rejects requests without setup commands: %j',
async setupCommands => {
await expect(
buildWorkspaceBackupCandidate({ ...eligibleRequest, setupCommands })
).resolves.toBeNull();
}
);

it.each([[['npm ci']], [['echo first', 'custom-tool --prepare', 'npm test']]])(
'accepts fresh repository requests with setup commands: %j',
it.each([[undefined], [[]], [['npm ci']], [['echo first', 'custom-tool --prepare', 'npm test']]])(
'accepts fresh repository requests regardless of setup commands: %j',
async setupCommands => {
await expect(
buildWorkspaceBackupCandidate({ ...eligibleRequest, setupCommands })
Expand Down Expand Up @@ -111,6 +102,7 @@ describe('workspace backup cache policy', () => {
repository: { type: 'github', repo: 'acme/other' },
}),
buildWorkspaceBackupCandidate({ ...eligibleRequest, shallow: false }),
buildWorkspaceBackupCandidate({ ...eligibleRequest, setupCommands: [] }),
buildWorkspaceBackupCandidate({ ...eligibleRequest, setupCommands: ['npm ci'] }),
buildWorkspaceBackupCandidate({
...eligibleRequest,
Expand All @@ -121,7 +113,7 @@ describe('workspace backup cache policy', () => {
}),
]);

expect(new Set([base?.digest, ...variants.map(value => value?.digest)]).size).toBe(6);
expect(new Set([base?.digest, ...variants.map(value => value?.digest)]).size).toBe(7);
});

it('canonicalizes setup environment key order', async () => {
Expand Down
8 changes: 1 addition & 7 deletions services/cloud-agent-next/src/workspace-backup-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,7 @@ function ownersEqual(left: WorkspaceBackupOwner, right: WorkspaceBackupOwner): b
export async function buildWorkspaceBackupCandidate(
request: WorkspaceBackupCandidateRequest
): Promise<WorkspaceBackupCandidate | null> {
if (
!request.fresh ||
request.devcontainer ||
request.userId.length === 0 ||
request.orgId === '' ||
!request.setupCommands?.length
)
if (!request.fresh || request.devcontainer || request.userId.length === 0 || request.orgId === '')
return null;

const canonicalRepository = canonicalizeRepository(request.repository);
Expand Down