import { expect, tap } from '@git.zone/tstest/tapbundle'; import * as smartstorage from '../ts/index.js'; const TEST_PORT = 3353; let testSmartStorageInstance: smartstorage.SmartStorage; tap.test('setup: start storage server for operational endpoint checks', async () => { testSmartStorageInstance = await smartstorage.SmartStorage.createAndStart({ server: { port: TEST_PORT, silent: true, region: 'us-east-1', }, storage: { cleanSlate: true, }, auth: { enabled: false, credentials: [], }, }); }); tap.test('operational endpoints expose live ready health and metrics', async () => { const live = await fetch(`http://localhost:${TEST_PORT}/-/live`); expect(live.status).toEqual(200); expect((await live.json()).status).toEqual('alive'); const ready = await fetch(`http://localhost:${TEST_PORT}/-/ready`); expect(ready.status).toEqual(200); expect((await ready.json()).status).toEqual('ready'); const health = await fetch(`http://localhost:${TEST_PORT}/-/health`); expect(health.status).toEqual(200); const healthBody = await health.json(); expect(healthBody.ok).toEqual(true); expect(healthBody.cluster.enabled).toEqual(false); const metrics = await fetch(`http://localhost:${TEST_PORT}/-/metrics`); expect(metrics.status).toEqual(200); const metricsBody = await metrics.text(); expect(metricsBody.includes('smartstorage_requests_total')).toEqual(true); expect(metricsBody.includes('smartstorage_cluster_enabled 0')).toEqual(true); }); tap.test('teardown: stop storage server', async () => { await testSmartStorageInstance.stop(); }); export default tap.start();