Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: only reset dialect result when it has changed #1471

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import java.sql.SQLException;
import java.sql.Savepoint;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import org.junit.After;
import org.junit.Before;
Expand All @@ -54,6 +55,8 @@

@RunWith(Parameterized.class)
public class SavepointMockServerTest extends AbstractMockServerTest {
private static Dialect currentDialect;

@Parameter public Dialect dialect;

@Parameters(name = "dialect = {0}")
Expand All @@ -63,13 +66,18 @@ public static Object[] data() {

@Before
public void setupDialect() {
mockSpanner.putStatementResult(StatementResult.detectDialectResult(this.dialect));
// Only reset the dialect result when it has actually changed. This prevents the SpannerPool
// from being closed after each test, which again makes the test slower.
if (!Objects.equals(this.dialect, currentDialect)) {
currentDialect = this.dialect;
mockSpanner.putStatementResult(StatementResult.detectDialectResult(this.dialect));
SpannerPool.closeSpannerPool();
}
}

@After
public void clearRequests() {
mockSpanner.clearRequests();
SpannerPool.closeSpannerPool();
}

private String createUrl() {
Expand Down
Loading