Skip to content

Commit adfec44

Browse files
committed
test(service-job,service-automation): bind the two new engine doubles to assertEngineUpdateDispatch (#5548)
1 parent 439349e commit adfec44

5 files changed

Lines changed: 21 additions & 2 deletions

File tree

packages/services/service-automation/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
},
2525
"devDependencies": {
2626
"@objectstack/driver-sql": "workspace:*",
27+
"@objectstack/metadata-core": "workspace:*",
2728
"@objectstack/objectql": "workspace:*",
2829
"@objectstack/plugin-security": "workspace:*",
2930
"@objectstack/service-job": "workspace:*",

packages/services/service-automation/src/builtin/wait-node-degraded-run.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
22

33
import { describe, it, expect } from 'vitest';
4+
import { assertEngineUpdateDispatch } from '@objectstack/metadata-core';
45
import { DbJobAdapter } from '@objectstack/service-job';
56
import type { IJobService, JobSchedule, JobHandler } from '@objectstack/spec/contracts';
67
import { AutomationEngine } from '../engine.js';
@@ -66,7 +67,11 @@ function makeFakeEngine() {
6667
tables.set(table, t);
6768
return { id: data.id };
6869
},
69-
async update(table: string, patch: any) {
70+
async update(table: string, patch: any, options?: any) {
71+
// Same binding as the sibling double in `service-job`: the fake refuses
72+
// exactly what `ObjectQLEngine.update` refuses, so the audit writes this
73+
// test asserts are writes a real server would have accepted.
74+
assertEngineUpdateDispatch(patch, options);
7075
const t = tables.get(table) ?? [];
7176
const r = t.find((x) => x.id === patch.id);
7277
if (!r) throw new Error(`row ${patch.id} not in ${table}`);

packages/services/service-job/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"croner": "^10.0.1"
2626
},
2727
"devDependencies": {
28+
"@objectstack/metadata-core": "workspace:*",
2829
"@types/node": "^26.1.2",
2930
"typescript": "^6.0.3",
3031
"vitest": "^4.1.10"

packages/services/service-job/src/db-job-adapter.degraded-outcome.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
22

33
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
4+
import { assertEngineUpdateDispatch } from '@objectstack/metadata-core';
45
import type { JobRunOutcome } from '@objectstack/spec/contracts';
56
import { DbJobAdapter } from './db-job-adapter.js';
67
import { IntervalJobAdapter } from './interval-job-adapter.js';
@@ -39,7 +40,12 @@ function makeFakeEngine() {
3940
tables.set(table, t);
4041
return { id: data.id };
4142
},
42-
async update(table: string, patch: any) {
43+
async update(table: string, patch: any, options?: any) {
44+
// Bind the double to the producer's own dispatch rule rather than
45+
// mirroring it by hand: `DbJobAdapter` always updates by a scalar
46+
// payload id, and a fake that accepts a call a real server answers 500
47+
// to would let that drift through unnoticed.
48+
assertEngineUpdateDispatch(patch, options);
4349
const t = tables.get(table) ?? [];
4450
const r = t.find((x) => x.id === patch.id);
4551
if (!r) throw new Error(`row ${patch.id} not in ${table}`);

pnpm-lock.yaml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)