Close endpoint failure types across service and web boundaries
This commit is contained in:
parent
fb94ea2c23
commit
390434bed1
2 changed files with 266 additions and 72 deletions
|
|
@ -51,7 +51,7 @@ test('partial delete recovery preserves only unfinished identities', () => {
|
|||
path: 'uncertain',
|
||||
operation_id: 'uncertain-id',
|
||||
result: null,
|
||||
error: 'transport interrupted'
|
||||
error: 'object_store_unavailable'
|
||||
}
|
||||
],
|
||||
() => ids.shift()
|
||||
|
|
|
|||
|
|
@ -132,6 +132,43 @@ test('shared fixtures decode through every JSON transport method', async () => {
|
|||
);
|
||||
});
|
||||
|
||||
test('delete batch decoding enforces the typed item outcome', async () => {
|
||||
const failureClient = new BrowserProductClient(async () =>
|
||||
jsonResponse({
|
||||
results: [
|
||||
{
|
||||
path: 'folder/file.txt',
|
||||
operation_id: 'operation-1',
|
||||
result: null,
|
||||
error: 'database_unavailable'
|
||||
}
|
||||
]
|
||||
})
|
||||
);
|
||||
const failure = requireValue(
|
||||
await failureClient.deleteBatch({ body: fixtures.delete_batch_request })
|
||||
);
|
||||
assert.equal(failure.results[0].error, 'database_unavailable');
|
||||
|
||||
const invalidClient = new BrowserProductClient(async () =>
|
||||
jsonResponse({
|
||||
results: [
|
||||
{
|
||||
path: 'folder/file.txt',
|
||||
operation_id: 'operation-1',
|
||||
result: 'succeeded',
|
||||
error: 'object_store_unavailable'
|
||||
}
|
||||
]
|
||||
})
|
||||
);
|
||||
const invalid = await invalidClient.deleteBatch({
|
||||
body: fixtures.delete_batch_request
|
||||
});
|
||||
assert.equal(invalid.ok, false);
|
||||
assert.equal(invalid.failure.kind, 'unexpected-http');
|
||||
});
|
||||
|
||||
test('declared, undeclared, and network failures remain distinct without retries', async () => {
|
||||
const declaredClient = new BrowserProductClient(async () =>
|
||||
jsonResponse(
|
||||
|
|
|
|||
Loading…
Reference in a new issue