Copilot commented on code in PR #7255:
URL: https://github.com/apache/texera/pull/7255#discussion_r3699284490
##########
common/dao/src/test/scala/org/apache/texera/dao/SiteSettingsSpec.scala:
##########
@@ -18,10 +18,34 @@
package org.apache.texera.dao
+import org.apache.texera.dao.jooq.generated.Tables.SITE_SETTINGS
+import org.scalatest.BeforeAndAfterAll
+import org.scalatest.BeforeAndAfterEach
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
-class SiteSettingsSpec extends AnyFlatSpec with Matchers {
+class SiteSettingsSpec
+ extends AnyFlatSpec
+ with Matchers
+ with BeforeAndAfterAll
+ with BeforeAndAfterEach
+ with MockTexeraDB {
+
+ // Point SqlServer (used by SiteSettings.getInt/getLong internally) and the
test's
+ // own getDSLContext at the same embedded Postgres.
+ override protected def beforeAll(): Unit = initializeDBAndReplaceDSLContext()
+
+ override protected def afterAll(): Unit = closeConnectionPool()
Review Comment:
When overriding ScalaTest lifecycle hooks, it's safer to call
`super.beforeAll()` / `super.afterAll()` (and to wrap cleanup in `try/finally`)
so other mixed-in traits' hooks still run and cleanup is not skipped if
`closeConnectionPool()` throws. Several existing specs follow this pattern
(e.g.,
`file-service/src/test/scala/org/apache/texera/service/resource/DatasetAccessResourceSpec.scala:123-149`).
This issue also appears on line 40 of the same file.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]