Runner: Proxy und Startseite, register/wake (R12)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6cd50bba9f
commit
4afe7eb5cd
7 files changed
+360
-2
No files matched your search
@@ -17,8 +17,10 @@ const jobs = {
|
||||
queueLength: () => 0,
|
||||
};
|
||||
const stopped = [];
|
||||
const registered = [];
|
||||
const dev = {
|
||||
ensure: async (sub) => ({ sub, state: 'starting' }),
|
||||
register: async (sub, j) => { registered.push([sub, j]); return { state: 'sleeping', extra: 'x' }; },
|
||||
stop: async (sub) => { stopped.push(sub); },
|
||||
list: () => [],
|
||||
};
|
||||
@@ -133,3 +135,19 @@ test('readMemAvailable liest MemAvailable in Bytes', () => {
|
||||
writeFileSync(p, 'MemTotal: 8000000 kB\nMemFree: 100000 kB\nMemAvailable: 2048000 kB\n');
|
||||
assert.equal(readMemAvailable(p), 2048000 * 1024);
|
||||
});
|
||||
|
||||
test('PUT /dev/:sub: Auth, 400, 200 ⇒ register', async () => {
|
||||
await withServer(config, async (base) => {
|
||||
const put = (path, headers, body) => fetch(base + path, { method: 'PUT', headers, body: JSON.stringify(body) });
|
||||
assert.equal((await put('/dev/demo', { 'Content-Type': 'application/json' }, good)).status, 401);
|
||||
assert.equal((await put('/dev/demo', auth, { ...good, sub: 'andere' })).status, 400);
|
||||
assert.equal((await put('/dev/demo', auth, { ...good, sha: 'zz' })).status, 400);
|
||||
assert.equal((await put('/dev/DEMO', auth, good)).status, 400);
|
||||
assert.equal(registered.length, 0);
|
||||
const r = await put('/dev/demo', auth, good);
|
||||
assert.equal(r.status, 200);
|
||||
assert.deepEqual(await r.json(), { state: 'sleeping' });
|
||||
assert.equal(registered[0][0], 'demo');
|
||||
assert.equal(registered[0][1].repo, 'JUSN/demo');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user