mirror of
https://github.com/whyour/qinglong.git
synced 2026-09-23 12:05:27 +08:00
feat(ql3): surface bounded console run logs
This commit is contained in:
@@ -33,12 +33,32 @@ function run(overrides = {}) {
|
||||
};
|
||||
}
|
||||
|
||||
function attempt(overrides = {}) {
|
||||
return {
|
||||
id: 'attempt_123',
|
||||
runId: 'run_123',
|
||||
attempt: 2,
|
||||
status: 'running',
|
||||
executorType: 'local_process',
|
||||
executorHandle: 'private-executor-handle',
|
||||
logArtifactId: 'private-log-artifact-id',
|
||||
callbackSequence: 0,
|
||||
createdAtMs: 2_100,
|
||||
startedAtMs: 2_200,
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
test('returns the shared bounded Run projection without secret-adjacent fields', async () => {
|
||||
const route = createLocalApiRunReadRoute({
|
||||
async findRunById(runId) {
|
||||
assert.equal(runId, 'run_123');
|
||||
return run({ version: 0 });
|
||||
},
|
||||
async findLatestAttemptByRunId(runId) {
|
||||
assert.equal(runId, 'run_123');
|
||||
return attempt();
|
||||
},
|
||||
});
|
||||
|
||||
const response = await route.handle({
|
||||
@@ -48,6 +68,14 @@ test('returns the shared bounded Run projection without secret-adjacent fields',
|
||||
assert.equal(response.statusCode, 200);
|
||||
assert.equal(response.body.run.projectId, 'prj_default');
|
||||
assert.equal(response.body.run.version, 0);
|
||||
assert.deepEqual(response.body.run.latestAttempt, {
|
||||
id: 'attempt_123',
|
||||
attempt: 2,
|
||||
status: 'running',
|
||||
logAvailable: true,
|
||||
createdAtMs: 2_100,
|
||||
startedAtMs: 2_200,
|
||||
});
|
||||
assert.equal(JSON.stringify(response).includes('private'), false);
|
||||
});
|
||||
|
||||
@@ -57,6 +85,9 @@ test('collapses absent and cross-project Runs and fails closed on repository err
|
||||
async findRunById() {
|
||||
return value;
|
||||
},
|
||||
async findLatestAttemptByRunId() {
|
||||
throw new Error('must not inspect Attempt for an absent Run');
|
||||
},
|
||||
});
|
||||
assert.deepEqual(
|
||||
await route.handle({ projectId: 'prj_default', runId: 'run_123' }),
|
||||
@@ -67,9 +98,45 @@ test('collapses absent and cross-project Runs and fails closed on repository err
|
||||
async findRunById() {
|
||||
throw new Error('database unavailable');
|
||||
},
|
||||
async findLatestAttemptByRunId() {
|
||||
throw new Error('database unavailable');
|
||||
},
|
||||
});
|
||||
assert.deepEqual(
|
||||
await unavailable.handle({ projectId: 'prj_default', runId: 'run_123' }),
|
||||
{ statusCode: 503, body: { code: 'run_query_unavailable' } },
|
||||
);
|
||||
});
|
||||
|
||||
test('returns null without an Attempt and fails closed on invalid Attempt projections', async () => {
|
||||
const withoutAttempt = createLocalApiRunReadRoute({
|
||||
async findRunById() {
|
||||
return run();
|
||||
},
|
||||
async findLatestAttemptByRunId() {
|
||||
return null;
|
||||
},
|
||||
});
|
||||
const response = await withoutAttempt.handle({
|
||||
projectId: 'prj_default',
|
||||
runId: 'run_123',
|
||||
});
|
||||
assert.equal(response.statusCode, 200);
|
||||
assert.equal(response.body.run.latestAttempt, null);
|
||||
|
||||
const invalidAttempt = createLocalApiRunReadRoute({
|
||||
async findRunById() {
|
||||
return run();
|
||||
},
|
||||
async findLatestAttemptByRunId() {
|
||||
return attempt({ runId: 'another_run' });
|
||||
},
|
||||
});
|
||||
assert.deepEqual(
|
||||
await invalidAttempt.handle({
|
||||
projectId: 'prj_default',
|
||||
runId: 'run_123',
|
||||
}),
|
||||
{ statusCode: 503, body: { code: 'run_query_unavailable' } },
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user