Commit 2a23bc4
committed
test(postgres): stub current_schema() so the provider fixtures pass again
resolveSchema() issues `SELECT current_schema()` on its own Statement before
each method's real query. Seven tests predated that call and broke: those
stubbing only prepareStatement got the unstubbed-mock default null from
createStatement()
NullPointerException: Cannot invoke "java.sql.Statement.executeQuery(String)"
because "stmt" is null at resolveSchema(...:797)
and those stubbing createStatement handed resolveSchema the shared ResultSet,
so its getString(1) tripped strict stubbing against getString("tablename").
resolveSchema() is the first createStatement() caller in every method that
reaches the database, so returning a dedicated schemaStatement first and the
shared statement afterwards routes each to the right place. It answers "public",
keeping these fixtures on the historical schema so they go on asserting the
behaviour they were written for rather than the search_path change itself.
setUp() uses lenient() because the pure-Java tests (getDatabaseType,
getDefaultSchema) never touch the Connection and strict stubbing would fail them
over an unused stub. Three tests re-stub createStatement locally and had to
prepend schemaStatement themselves; getForeignKeys_returnsRelationships is left
alone because getForeignKeys does not call resolveSchema.
11/11 pass.1 parent f5196eb commit 2a23bc4
1 file changed
Lines changed: 28 additions & 3 deletions
Lines changed: 28 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
38 | 47 | | |
39 | | - | |
| 48 | + | |
40 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
41 | 63 | | |
42 | 64 | | |
43 | 65 | | |
| |||
47 | 69 | | |
48 | 70 | | |
49 | 71 | | |
50 | | - | |
| 72 | + | |
| 73 | + | |
51 | 74 | | |
52 | 75 | | |
53 | 76 | | |
| |||
209 | 232 | | |
210 | 233 | | |
211 | 234 | | |
212 | | - | |
| 235 | + | |
| 236 | + | |
213 | 237 | | |
214 | 238 | | |
215 | 239 | | |
| |||
281 | 305 | | |
282 | 306 | | |
283 | 307 | | |
| 308 | + | |
284 | 309 | | |
285 | 310 | | |
286 | 311 | | |
| |||
0 commit comments