Skip to content

Commit 193d084

Browse files
committed
test(bigquery): compare URL and body to each other, not to two literals
cubic found expect(serialized).not.toContain(' my-project ') could not fail: it was written when the fixture supplied a padded projectId, and once the strict guard made padding throw I unpadded the fixture and left the assertion behind. Changing a fixture silently defanged an assertion written for the old one. Padded refusal is covered where it belongs — NEWLY_TRIMMED_BY_THIS_CHANGE and the destructive-tool describe — so nothing is lost by dropping it. The expected body value is now derived from the URL rather than hard-coded, so the test is about agreement: if either side starts naming a different project it fails, whereas two independent literals both pass a change made to both. Verified by pointing the body at 'other-project' — fails now, would have passed before.
1 parent 345ef7f commit 193d084

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

apps/sim/tools/google_bigquery/path_safety.test.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,25 @@ describe('projectId agrees between URL and body', () => {
186186
const body = (tool.request?.body as ((p: typeof params) => unknown) | undefined)?.(params)
187187
const serialized = JSON.stringify(body)
188188

189-
expect(url.pathname).toContain('/projects/my-project/')
190-
expect(serialized).not.toContain(' my-project ')
191-
expect(serialized).toContain('"projectId":"my-project"')
189+
/**
190+
* The two sides are compared to **each other**, not to two independent
191+
* literals.
192+
*
193+
* This line previously read `expect(serialized).not.toContain(' my-project ')`,
194+
* which was meaningful only while the fixture supplied a padded id. Once the
195+
* strict guard made padding throw, the fixture became unpadded and that
196+
* assertion could no longer fail — changing a fixture silently defanged an
197+
* assertion written for the old one. Padded refusal is covered where it
198+
* belongs: `NEWLY_TRIMMED_BY_THIS_CHANGE` and the destructive-tool describe.
199+
*
200+
* Deriving the expected body value from the URL keeps this test about
201+
* agreement: if either side starts naming a different project, it fails,
202+
* whereas two hard-coded literals both pass a change made to both.
203+
*/
204+
const urlProject = url.pathname.split('/projects/')[1]?.split('/')[0]
205+
206+
expect(urlProject).toBe('my-project')
207+
expect(serialized).toContain(`"projectId":"${urlProject}"`)
192208
})
193209
})
194210

0 commit comments

Comments
 (0)