feat(speedtest): worker + hourly cron + history/run routes
Adds speedtest pg-boss worker with injectable runner for testing, hourly cron enqueue, and /api/speedtest/history (GET) + /run (POST, owner-only) routes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
15
tests/api/speedtest.test.js
Normal file
15
tests/api/speedtest.test.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import { describe, it, expect, beforeAll } from 'vitest';
|
||||
import request from 'supertest';
|
||||
import { setup } from './helpers.js';
|
||||
import * as repo from '../../lib/db/repos/speedtest.js';
|
||||
|
||||
let app, ownerHeaders;
|
||||
beforeAll(async () => { ({ app, ownerHeaders } = await setup()); await repo.record({ down_mbps: 50, up_mbps: 10, ping_ms: 12 }); });
|
||||
describe('speedtest api', () => {
|
||||
it('401 without auth', async () => expect((await request(app).get('/api/speedtest/history')).status).toBe(401));
|
||||
it('history returns rows', async () => {
|
||||
const res = await request(app).get('/api/speedtest/history').set(ownerHeaders);
|
||||
expect(res.status).toBe(200);
|
||||
expect(res.body.length).toBeGreaterThanOrEqual(1);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user