website refactor
This commit is contained in:
@@ -155,26 +155,27 @@ export class IntegrationTestHarness {
|
||||
* Helper to verify constraint violations
|
||||
*/
|
||||
async expectConstraintViolation(
|
||||
operation: () => Promise<any>,
|
||||
operation: () => Promise<unknown>,
|
||||
expectedConstraint?: string
|
||||
): Promise<void> {
|
||||
try {
|
||||
await operation();
|
||||
throw new Error('Expected constraint violation but operation succeeded');
|
||||
} catch (error: any) {
|
||||
} catch (error) {
|
||||
// Check if it's a constraint violation
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
const isConstraintError =
|
||||
error.message?.includes('constraint') ||
|
||||
error.message?.includes('23505') || // Unique violation
|
||||
error.message?.includes('23503') || // Foreign key violation
|
||||
error.message?.includes('23514'); // Check violation
|
||||
message.includes('constraint') ||
|
||||
message.includes('23505') || // Unique violation
|
||||
message.includes('23503') || // Foreign key violation
|
||||
message.includes('23514'); // Check violation
|
||||
|
||||
if (!isConstraintError) {
|
||||
throw new Error(`Expected constraint violation but got: ${error.message}`);
|
||||
throw new Error(`Expected constraint violation but got: ${message}`);
|
||||
}
|
||||
|
||||
if (expectedConstraint && !error.message.includes(expectedConstraint)) {
|
||||
throw new Error(`Expected constraint '${expectedConstraint}' but got: ${error.message}`);
|
||||
if (expectedConstraint && !message.includes(expectedConstraint)) {
|
||||
throw new Error(`Expected constraint '${expectedConstraint}' but got: ${message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user