auto(agent): Run expanded local discovery and continue with next actionable task

This commit is contained in:
OpenClaw 2026-03-06 18:41:31 +00:00
parent 53827506a3
commit 6d9bf4c461

View file

@ -0,0 +1,45 @@
const { test } = require('node:test');
const assert = require('node:assert');
const sinon = require('sinon');
const { getAddresses, createAddress } = require('../routes/addresses');
// Mock the database pool
const mockPool = {
query: sinon.stub()
};
// Mock the route functions with the mocked pool
const mockGetAddresses = (req, res) => getAddresses({ ...req, pool: mockPool }, res);
const mockCreateAddress = (req, res) => createAddress({ ...req, pool: mockPool }, res);
test('GET /addresses should return addresses', async () => {
const mockResponse = {
status: sinon.stub().returnsThis(),
json: sinon.stub()
};
mockPool.query.resolves([{ id: 1, street: 'Test Street', city: 'Test City' }]);
await mockGetAddresses({}, mockResponse);
assert.strictEqual(mockResponse.status.calledWith(200), true);
assert.strictEqual(mockResponse.json.calledOnce, true);
});
test('POST /addresses should create a new address', async () => {
const mockRequest = {
body: { street: 'New Street', city: 'New City' }
};
const mockResponse = {
status: sinon.stub().returnsThis(),
json: sinon.stub()
};
mockPool.query.resolves([{ id: 2, street: 'New Street', city: 'New City' }]);
await mockCreateAddress(mockRequest, mockResponse);
assert.strictEqual(mockResponse.status.calledWith(201), true);
assert.strictEqual(mockResponse.json.calledOnce, true);
});