Files
harbor-net/test/server/dataplane-client.test.js
Dmitriy Petrov b0b9da51b6
All checks were successful
Build and Deploy Gateway / build-and-push (push) Successful in 13s
Build and Deploy Gateway / deploy (push) Successful in 12s
Split gateway control and dataplane into separate services
2026-07-11 17:52:48 +03:00

24 lines
849 B
JavaScript

import assert from 'node:assert/strict';
import test from 'node:test';
import { createDataplaneClient } from '../../src/server/dataplaneClient.js';
test('control uses the dataplane socket protocol', async () => {
const requests = [];
const send = async (socketPath, pathname, method) => {
requests.push(`${method} ${pathname} ${socketPath}`);
return { running: pathname !== '/stop', startedAt: 'now' };
};
const client = createDataplaneClient('/run/dataplane.sock', send);
assert.equal((await client.refresh()).running, true);
await client.apply();
await client.restart();
assert.equal((await client.stop()).running, false);
assert.deepEqual(requests, [
'GET /status /run/dataplane.sock',
'POST /apply /run/dataplane.sock',
'POST /restart /run/dataplane.sock',
'POST /stop /run/dataplane.sock',
]);
});