pgjdbc/pgjdbc GitHub issues and pull requests (mirror)  
help / color / mirror / Atom feed
[pgjdbc/pgjdbc] PR #4113: test: make message assertions locale-independent
4+ messages / 2 participants
[nested] [flat]

* [pgjdbc/pgjdbc] PR #4113: test: make message assertions locale-independent
@ 2026-05-26 12:01  "vlsi (@vlsi)" <[email protected]>
  0 siblings, 0 replies; 4+ messages in thread

From: vlsi (@vlsi) @ 2026-05-26 12:01 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

## What

Make exception-message assertions in four tests locale-independent. Wrap the expected text in `GT.tr(...)` so the comparison matches whatever the JVM's default locale resolves the template to.

Affected tests:

- `org.postgresql.jdbc.ScramTest`
  - `invalidPasswords`: wraps the expected text in `GT.tr(...)`.
  - `rejectIterationCountAboveDefaultCap`: drops the locale-dependent `contains("exceeds")` assertion. The remaining checks (the `scramMaxIterations` property name and the locale-formatted iteration count) already pin the test to the iteration-cap error path.
- `org.postgresql.test.jdbc2.PreparedStatementTest.testBadBoolean`: uses `GT.tr("Cannot cast to boolean: \"{0}\"", value)` for the message-with-value cases. The two `assertEquals("Cannot cast to boolean", ...)` calls stay as raw English literals because the source throws that literal without `GT.tr`.
- `org.postgresql.test.jdbc2.ResultSetTest`
  - text-mode branch of `testBadBoolean`: uses `GT.tr(...)`.
  - binary-mode branch: derives the locale-specific prefix, middle, and suffix from the `"Cannot convert the column of type {0} to requested type {1}."` template via placeholder markers, then checks the actual message lines up.
  - `testgetBoolean`: wraps the `"2"` and `"2.0"` cases in `GT.tr(...)`.
- `org.postgresql.test.jdbc2.UpdateableResultTest`: wraps the three `"No eligible primary or unique key found for table …"` asserts in `GT.tr(...)`.

## Why

The CI matrix runs jobs with `ru_RU` and other non-English locales. Production code routes the affected messages through `GT.tr` at the throw site, so the JVM picks up the localised string from the gettext catalogue. Hard-coded English assertions fail on those jobs even though the behaviour is correct.

The run that surfaced this: https://github.com/pgjdbc/pgjdbc/actions/runs/26416335971. Fourteen cases failed across the four classes above.

The `GT.tr(...)` pattern is already used in `PreparedStatementTest.checkInfinityLiterals`, so the fix follows existing precedent.

## How to verify

- Run the CI matrix with `ru_RU`; the 14 previously failing cases should pass.
- Run the CI matrix with the default English locale; `GT.tr(template, args)` returns the English template when no translation matches, so the assertions continue to pass.

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #4113: test: make message assertions locale-independent
@ 2026-05-26 13:08  "vlsi (@vlsi)" <[email protected]>
  2 siblings, 0 replies; 4+ messages in thread

From: vlsi (@vlsi) @ 2026-05-26 13:08 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

The test change is needed for https://github.com/pgjdbc/pgjdbc/pull/1280
If there are no objections, I am going to merge the PR soon.

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #4113: test: make message assertions locale-independent
@ 2026-05-26 15:42  "davecramer (@davecramer)" <[email protected]>
  2 siblings, 0 replies; 4+ messages in thread

From: davecramer (@davecramer) @ 2026-05-26 15:42 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

(on pgjdbc/src/test/java/org/postgresql/jdbc/ScramTest.java:147)

if it were me, I'd use `received` instead of `got`. There is some historical precedence for got being an "ugly word" in the English language. But I'm not going to die on this hill 

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #4113: test: make message assertions locale-independent
@ 2026-05-26 15:42  "davecramer (@davecramer)" <[email protected]>
  2 siblings, 0 replies; 4+ messages in thread

From: davecramer (@davecramer) @ 2026-05-26 15:42 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

LGTM

^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2026-05-26 15:42 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-05-26 12:01 [pgjdbc/pgjdbc] PR #4113: test: make message assertions locale-independent "vlsi (@vlsi)" <[email protected]>
2026-05-26 13:08 ` "vlsi (@vlsi)" <[email protected]>
2026-05-26 15:42 ` "davecramer (@davecramer)" <[email protected]>
2026-05-26 15:42 ` "davecramer (@davecramer)" <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox