Skip to content

Commit c8e2f32

Browse files
committed
Add test confirming close is issued for statements manually cleared
1 parent 494d47b commit c8e2f32

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

modules/tests/shared/src/test/scala/PrepareCacheTest.scala

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,25 @@ class PrepareCacheTest extends SkunkTest {
6767
}
6868
}
6969
}
70+
71+
pooledTest("statements manually cleared from parse cache are evicted upon session recycling", max = 1) { p =>
72+
p.use { s =>
73+
s.execute(pgStatementsByName)("foo").void >>
74+
s.execute(pgStatementsByStatement)("bar").void >>
75+
s.execute(pgStatementsCountByStatement)("baz").void >>
76+
s.parseCache.value.clear >>
77+
s.parseCache.value.values.map { values =>
78+
assertEquals(values.size, 0, "no prepared statements are cached")
79+
} >>
80+
s.execute(pgStatementsCount).map { count =>
81+
assertEquals(count, List(3L), "evicted prepared statements should still exist on server")
82+
}
83+
} >>
84+
p.use { s =>
85+
// verify all statements were closed
86+
s.execute(pgStatements).map { statements =>
87+
assertEquals(statements, Nil)
88+
}
89+
}
90+
}
7091
}

0 commit comments

Comments
 (0)