gizmoduck: row 270: the bus legacy test inserts its legacy thread by hand (sessions is append-only) and the test business has the assistant thread.create needs; not run
This commit is contained in:
1 parent
09b20784f6
commit
48c34539c3
1 file changed
+18
-7
@@ -1,14 +1,18 @@
|
|||||||
import test from 'node:test';
|
import test from 'node:test';
|
||||||
import assert from 'node:assert/strict';
|
import assert from 'node:assert/strict';
|
||||||
import { mkdtempSync, rmSync } from 'node:fs';
|
import { randomUUID } from 'node:crypto';
|
||||||
|
import { mkdtempSync, readFileSync, rmSync } from 'node:fs';
|
||||||
import { tmpdir } from 'node:os';
|
import { tmpdir } from 'node:os';
|
||||||
import { join } from 'node:path';
|
import { join } from 'node:path';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
import { Store } from '../src/store.mjs';
|
import { Store } from '../src/store.mjs';
|
||||||
import { Broker } from '../src/broker.mjs';
|
import { Broker } from '../src/broker.mjs';
|
||||||
|
|
||||||
// Row 270 (264c, #1775, T1 item 7 D6): session.list's `compactions` key, from the host's ledger
|
// Row 270 (264c, #1775, T1 item 7 D6): session.list's `compactions` key, from the host's ledger
|
||||||
// reader (runtime.mjs gives the seat's compactionCount). The reader itself is
|
// reader (runtime.mjs gives the seat's compactionCount). The reader itself is
|
||||||
// packages/seat/tests/compactions.test.mjs's.
|
// packages/seat/tests/compactions.test.mjs's.
|
||||||
|
const shipped = (name) =>
|
||||||
|
JSON.parse(readFileSync(fileURLToPath(new URL(`../../../roles/${name}.json`, import.meta.url)), 'utf8'));
|
||||||
const businesses = {
|
const businesses = {
|
||||||
demo: {
|
demo: {
|
||||||
id: 'demo',
|
id: 'demo',
|
||||||
@@ -16,9 +20,10 @@ const businesses = {
|
|||||||
arbiters: { technical: 'pm', delivery: 'chief' },
|
arbiters: { technical: 'pm', delivery: 'chief' },
|
||||||
roles: {
|
roles: {
|
||||||
chief: { definition: 'chief-of-staff', authority: { withinRole: ['message.send'], crossRole: [] } },
|
chief: { definition: 'chief-of-staff', authority: { withinRole: ['message.send'], crossRole: [] } },
|
||||||
|
assistant: { definition: 'assistant', authority: { withinRole: ['message.send'], crossRole: [] } },
|
||||||
pm: { definition: 'pm', authority: { withinRole: ['message.send'], crossRole: [] } },
|
pm: { definition: 'pm', authority: { withinRole: ['message.send'], crossRole: [] } },
|
||||||
},
|
},
|
||||||
definitions: { 'chief-of-staff': {}, pm: {} },
|
definitions: { 'chief-of-staff': {}, assistant: { messaging: shipped('assistant').messaging }, pm: {} },
|
||||||
projects: { stack: { root: '/nonexistent' } },
|
projects: { stack: { root: '/nonexistent' } },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -35,7 +40,7 @@ function setup(t, options = {}) {
|
|||||||
const call = (verb, args = {}) => b.request(human, { verb, args });
|
const call = (verb, args = {}) => b.request(human, { verb, args });
|
||||||
const project = call('project.create', { name: 'stack work', repo: 'stack' }).id;
|
const project = call('project.create', { name: 'stack work', repo: 'stack' }).id;
|
||||||
const A = call('thread.create', { project, name: 'alpha' }).id;
|
const A = call('thread.create', { project, name: 'alpha' }).id;
|
||||||
return { store, call, A };
|
return { store, call, project, A };
|
||||||
}
|
}
|
||||||
|
|
||||||
test('session.list rows carry the reader count for each session, with its store identity', (t) => {
|
test('session.list rows carry the reader count for each session, with its store identity', (t) => {
|
||||||
@@ -56,13 +61,19 @@ test('session.list rows carry the reader count for each session, with its store
|
|||||||
assert.ok(rows.every((r) => !('op' in r)));
|
assert.ok(rows.every((r) => !('op' in r)));
|
||||||
});
|
});
|
||||||
|
|
||||||
// A legacy session (op legacy-3l, from the 3k-3l migration) keeps the thread's store.
|
// A legacy session (op legacy-3l, from the 3k-3l migration, its id the thread's) keeps the
|
||||||
|
// thread's store. The thread is made by hand with the session the migration gives it, as
|
||||||
|
// message-filter.test.mjs does; sessions is append-only.
|
||||||
test('a legacy session is asked for with legacy true', (t) => {
|
test('a legacy session is asked for with legacy true', (t) => {
|
||||||
const asked = [];
|
const asked = [];
|
||||||
const f = setup(t, { compactions: (q) => (asked.push(q), { count: 0, known: true, reason: null, at: null }) });
|
const f = setup(t, { compactions: (q) => (asked.push(q), { count: 0, known: true, reason: null, at: null }) });
|
||||||
f.store.run("UPDATE sessions SET op='legacy-3l' WHERE thread=?", f.A);
|
const L = randomUUID();
|
||||||
f.call('session.list', { thread: f.A });
|
const at = '2026-10-21T00:00:00.000Z';
|
||||||
assert.deepEqual(asked.map((q) => q.legacy), [true]);
|
f.store.run('INSERT INTO threads(id,at,business,project,instance,owner,name) VALUES(?,?,?,?,?,?,?)', L, at, 'demo', f.project, 'assistant', 'jason', 'legacy');
|
||||||
|
f.store.run("INSERT INTO sessions(at,business,thread,id,instance,owner,name,op) SELECT at,business,id,id,instance,owner,'default','legacy-3l' FROM threads WHERE id=?", L);
|
||||||
|
f.store.run("INSERT INTO session_defaults(at,thread,session,by) SELECT at,id,id,'migration-3l' FROM threads WHERE id=?", L);
|
||||||
|
f.call('session.list', { thread: L });
|
||||||
|
assert.deepEqual(asked, [{ business: 'demo', thread: L, session: L, legacy: true }]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('without a reader the count is unknown, never 0; a reader that throws is store-unreadable', (t) => {
|
test('without a reader the count is unknown, never 0; a reader that throws is store-unreadable', (t) => {
|
||||||
|
|||||||
Reference in new issue
Block a user