// Run after `npm run build`. // mosquitto_ctrl runs inside the broker's own container when the manifest names it, so a machine // needs no mosquitto package (whose index may be too stale to install from) and the tool always // matches the broker's version. import assert from "node:assert/strict"; import { test } from "node:test"; import { MosquittoClient } from "../dist/client.js"; // compiled: client.ts uses parameter properties, which type stripping cannot run const env = { MESH_PROVISION_MQTT: "127.0.0.1:21883", MESH_MQTT_PASSWORD: "pw" }; test("named, the broker's container runs mosquitto_ctrl", () => { const c = MosquittoClient.fromEnv({ ...env, MESH_MQTT_CTRL_CONTAINER: "mosquitto" }); assert.deepEqual(c.ctrl(["dynsec", "listClients"]), ["docker", ["exec", "mosquitto", "mosquitto_ctrl", "dynsec", "listClients"]]); }); test("unnamed, this machine's mosquitto_ctrl runs", () => { const c = MosquittoClient.fromEnv(env); assert.deepEqual(c.ctrl(["dynsec", "listClients"]), ["mosquitto_ctrl", ["dynsec", "listClients"]]); });