Friendly app-level validation for a RANGE with end-before-start (#678) #706
@@ -612,6 +612,29 @@ class DocumentRepositoryTest {
|
||||
.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 ─────────────────────────────────────────────────────
|
||||
|
||||
private Document uploaded(String title) {
|
||||
|
||||
Reference in New Issue
Block a user