test(document): prove Postgres accepts an equal-date RANGE (#678)
All checks were successful
CI / Unit & Component Tests (pull_request) Successful in 3m19s
CI / OCR Service Tests (pull_request) Successful in 21s
CI / Backend Unit Tests (pull_request) Successful in 3m43s
CI / fail2ban Regex (pull_request) Successful in 43s
CI / Semgrep Security Scan (pull_request) Successful in 20s
CI / Compose Bucket Idempotency (pull_request) Successful in 1m4s
All checks were successful
CI / Unit & Component Tests (pull_request) Successful in 3m19s
CI / OCR Service Tests (pull_request) Successful in 21s
CI / Backend Unit Tests (pull_request) Successful in 3m43s
CI / fail2ban Regex (pull_request) Successful in 43s
CI / Semgrep Security Scan (pull_request) Successful in 20s
CI / Compose Bucket Idempotency (pull_request) Successful in 1m4s
Testcontainers integration test persisting a RANGE doc with end == start against real Postgres + Flyway, which (unlike H2) enforces the V69 chk_meta_date_end_after_start CHECK. Pins the app guard's isBefore semantics to the actual >= constraint, guarding against app/DB drift (AC2). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -612,6 +612,29 @@ class DocumentRepositoryTest {
|
|||||||
.isLessThanOrEqualTo(5);
|
.isLessThanOrEqualTo(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ─── V69 date-range CHECK constraints (#678) ──────────────────────────────
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void save_acceptsRange_whenEndEqualsStart() {
|
||||||
|
// chk_meta_date_end_after_start is end >= start, so equal dates are valid.
|
||||||
|
// Real Postgres + Flyway here (H2 would not enforce the CHECK) pins the
|
||||||
|
// app guard's isBefore semantics to the actual constraint — guards drift (AC2).
|
||||||
|
LocalDate day = LocalDate.of(1917, 1, 10);
|
||||||
|
Document saved = documentRepository.saveAndFlush(Document.builder()
|
||||||
|
.title("Gleicher Tag")
|
||||||
|
.originalFilename("gleicher_tag.pdf")
|
||||||
|
.status(DocumentStatus.UPLOADED)
|
||||||
|
.documentDate(day)
|
||||||
|
.metaDatePrecision(DatePrecision.RANGE)
|
||||||
|
.metaDateEnd(day)
|
||||||
|
.build());
|
||||||
|
|
||||||
|
Document found = documentRepository.findById(saved.getId()).orElseThrow();
|
||||||
|
assertThat(found.getDocumentDate()).isEqualTo(day);
|
||||||
|
assertThat(found.getMetaDateEnd()).isEqualTo(day);
|
||||||
|
assertThat(found.getMetaDatePrecision()).isEqualTo(DatePrecision.RANGE);
|
||||||
|
}
|
||||||
|
|
||||||
// ─── seeding helpers ─────────────────────────────────────────────────────
|
// ─── seeding helpers ─────────────────────────────────────────────────────
|
||||||
|
|
||||||
private Document uploaded(String title) {
|
private Document uploaded(String title) {
|
||||||
|
|||||||
Reference in New Issue
Block a user