Files
gridpilot.gg/tests/integration/database/constraints/foreign-key-constraints.integration.test.ts
Marc Mintel a0f41f242f
Some checks failed
CI / lint-typecheck (pull_request) Failing after 4m51s
CI / tests (pull_request) Has been skipped
CI / contract-tests (pull_request) Has been skipped
CI / e2e-tests (pull_request) Has been skipped
CI / comment-pr (pull_request) Has been skipped
CI / commit-types (pull_request) Has been skipped
integration tests
2026-01-23 00:46:34 +01:00

53 lines
1.5 KiB
TypeScript

import { describe, it, expect, beforeEach } from 'vitest';
import { DatabaseTestContext, DriverData } from '../DatabaseTestContext';
describe('Database Constraints - Foreign Key Constraint Violations', () => {
let context: DatabaseTestContext;
beforeEach(() => {
context = DatabaseTestContext.create();
});
it('should handle non-existent driver in team creation', async () => {
// Given: No driver exists with the given ID
// When: Attempt to create a team with non-existent owner
const result = await context.createTeamUseCase.execute({
name: 'Test Team',
tag: 'TT',
description: 'A test team',
ownerId: 'non-existent-driver',
leagues: [],
});
// Then: Should fail with appropriate error
expect(result.isErr()).toBe(true);
if (result.isErr()) {
expect(result.error.code).toBe('VALIDATION_ERROR');
}
});
it('should handle non-existent team in join request', async () => {
// Given: A driver exists
const driver: DriverData = {
id: 'driver-123',
iracingId: '12345',
name: 'Test Driver',
country: 'US',
joinedAt: new Date(),
};
await context.driverRepository.create(driver);
// When: Attempt to join non-existent team
const result = await context.joinTeamUseCase.execute({
teamId: 'non-existent-team',
driverId: driver.id,
});
// Then: Should fail with appropriate error
expect(result.isErr()).toBe(true);
if (result.isErr()) {
expect(result.error.code).toBe('TEAM_NOT_FOUND');
}
});
});