Skip to content

Commit 488c2fe

Browse files
committed
test(spec): the external-binding refusal tests assert the envelope and the named subject, not the remedy's wording
Claude-Session: https://claude.ai/code/session_013dX1BHfcVSJNSkfA6cvwJN Co-authored-by: Claude <noreply@anthropic.com>
1 parent 03234e2 commit 488c2fe

2 files changed

Lines changed: 7 additions & 12 deletions

File tree

‎packages/spec/src/data/external-binding-datasource.test.ts‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,11 @@ describe('ObjectSchema refuses an `external` binding on the primary datasource',
3737
['`datasource` omitted', { external: { remoteName: 'orders' } }],
3838
["`datasource: 'default'`", { datasource: 'default', external: { remoteName: 'orders' } }],
3939
['an empty binding', { external: {} }],
40-
])('%s: one issue at `external`, naming the rule and both fixes', (_label, extra) => {
40+
])('%s: one issue at `external`, naming the object and its datasource', (_label, extra) => {
4141
const issues = issuesOf(object(extra));
4242
expect(issues).toHaveLength(1);
4343
expect(issues[0]).toMatchObject({ code: 'custom', path: ['external'] });
4444
expect(issues[0]!.message).toMatch(PRIMARY);
45-
expect(issues[0]!.message).toContain("ADR-0015 §4.2 allows `external` only on a datasource whose `schemaMode` is not 'managed'.");
46-
expect(issues[0]!.message).toContain("declared with `schemaMode: 'external'` (or 'validate-only')");
47-
expect(issues[0]!.message).toContain('or remove `external` to keep this a managed object.');
4845
});
4946

5047
it('`ObjectSchema.create` refuses it at module load, with the same issue', () => {

‎packages/spec/src/stack-external-binding-datasource.test.ts‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,12 @@ describe('defineStack — an `external` binding on a managed datasource the stac
4848
it.each([
4949
["`schemaMode: 'managed'`", { schemaMode: 'managed' }],
5050
['no `schemaMode` (managed by default)', {}],
51-
])('%s: STACK_CROSS_REFERENCE_INVALID, 422, one finding naming the object, the datasource and both fixes', (_label, mode) => {
51+
])('%s: STACK_CROSS_REFERENCE_INVALID, 422, one finding naming the object and the datasource', (_label, mode) => {
5252
const err = refusalOf({ datasources: [warehouse(mode)], objects: [order({ datasource: 'warehouse' })] });
5353
expect(err?.code).toBe('STACK_CROSS_REFERENCE_INVALID');
5454
expect(err?.status).toBe(422);
55-
expect(err?.message).toMatch(/^defineStack cross-reference validation failed \(1 issue\):/);
5655
expect(err?.issues).toHaveLength(1);
57-
const finding = String(err!.issues![0]);
58-
expect(finding).toMatch(/^Object 'wh_order' declares `external` on datasource 'warehouse', whose `schemaMode` is 'managed'/);
59-
expect(finding).toContain("ADR-0015 §4.2 allows `external` only on a datasource whose `schemaMode` is not 'managed'.");
60-
expect(finding).toContain("declare it with `schemaMode: 'external'` (or 'validate-only')");
56+
expect(String(err!.issues![0])).toMatch(/^Object 'wh_order' declares `external` on datasource 'warehouse', whose `schemaMode` is 'managed'/);
6157
});
6258

6359
it('one finding per bound object; an unbound object on the same datasource is not one', () => {
@@ -101,7 +97,6 @@ describe('defineStack — an `external` binding on the primary datasource', () =
10197
expect(err?.issues).toEqual([
10298
expect.objectContaining({ code: 'custom', path: ['objects', 0, 'external'] }),
10399
]);
104-
expect(err?.message).toContain("objects.0.external: Object 'wh_order' declares `external`, but its `datasource` is 'default'");
105100
});
106101

107102
it('a package `defaultDatasource` naming an external datasource does not make the object federated', () => {
@@ -111,6 +106,9 @@ describe('defineStack — an `external` binding on the primary datasource', () =
111106
objects: [order()],
112107
});
113108
expect(err?.code).toBe('STACK_SCHEMA_INVALID');
114-
expect(err?.message).toContain('A package `defaultDatasource` or a `datasourceMapping` rule does not count');
109+
expect(err?.status).toBe(422);
110+
expect(err?.issues).toEqual([
111+
expect.objectContaining({ code: 'custom', path: ['objects', 0, 'external'] }),
112+
]);
115113
});
116114
});

0 commit comments

Comments
 (0)