@bongos/core 1.21.157 → 1.21.159

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -195,6 +195,7 @@ test('store: a key or version that could escape the store dir is refused before
195
195
  // A fake pg pool: `state` is the registry, answers are computed from it.
196
196
  function fakeDb(state = { modules: {}, versions: [] }) {
197
197
  const log = [];
198
+ state.channels = state.channels || [];
198
199
  const client = {
199
200
  async query(sql, params = []) {
200
201
  log.push(sql.trim().split(/\s+/).slice(0, 2).join(' '));
@@ -211,6 +212,10 @@ function fakeDb(state = { modules: {}, versions: [] }) {
211
212
  const row = { id: state.versions.length + 1, module_key: params[0], version: params[1] };
212
213
  state.versions.push(row); return { rows: [row] };
213
214
  }
215
+ if (/^INSERT INTO store_module_version_channels/.test(sql)) {
216
+ state.channels.push({ version_id: params[0], channel: params[1], reason: params[2], set_by: params[3] });
217
+ return { rows: [] };
218
+ }
214
219
  return { rows: [] };
215
220
  },
216
221
  release() {},
@@ -256,6 +261,33 @@ test('registry: a version is published once, and never older than the latest', a
256
261
  assert.equal(ok.ok, true, 'numeric, not string, ordering: 1.10.0 > 1.2.0');
257
262
  });
258
263
 
264
+ // Task 1003803, ADR 0344 D2: every new version, first release or update, lands on
265
+ // the tester channel. Publish takes no channel at all, so there is no flag to omit
266
+ // or misspell; reaching everyone is the promotion gate's later act (task 1003804).
267
+ test('channel: a first release lands on tester, recorded with who published it', async () => {
268
+ const db = fakeDb();
269
+ const r = await store.publishVersion(input(), { db: db.pool });
270
+ assert.equal(r.ok, true);
271
+ assert.equal(r.channel, 'tester');
272
+ assert.deepEqual(db.state.channels, [{ version_id: 1, channel: 'tester', reason: 'new_version', set_by: 7 }]);
273
+ });
274
+
275
+ test('channel: an update lands on tester too, never straight to general', async () => {
276
+ const state = { modules: { weather: { module_key: 'weather', author_id: 7, status: 'listed' } },
277
+ versions: [{ id: 1, module_key: 'weather', version: '1.1.0' }] };
278
+ const db = fakeDb(state);
279
+ const r = await store.publishVersion(input({ channel: 'general' }), { db: db.pool });
280
+ assert.equal(r.ok, true);
281
+ assert.equal(r.channel, 'tester', 'a channel named by the caller is not a way past testers');
282
+ assert.deepEqual(db.state.channels.map((c) => c.channel), ['tester']);
283
+ });
284
+
285
+ test('channel: a refused publish records no channel', async () => {
286
+ const db = fakeDb({ modules: { weather: { module_key: 'weather', author_id: 7, status: 'listed' } }, versions: [] });
287
+ await store.publishVersion(input({ builderId: 8 }), { db: db.pool });
288
+ assert.deepEqual(db.state.channels, []);
289
+ });
290
+
259
291
  test('registry: if putting the file in place fails, the row is rolled back', async () => {
260
292
  const db = fakeDb();
261
293
  await assert.rejects(