ChangeRebuilderIT: Reopen ReviewDb when changing migration state
These tests commonly use methods on TestNotesMigration to play around with the migration state. However, this wasn't taking into account the fact that the migration state affects whether a ReviewDb opened by the SchemaFactory is wrapped in a DisabledReviewDbChangesWrapper. Unfortunately the request scope implementation used in tests caches an open ReviewDb, meaning that depending on when the ReviewDb was first opened, the cached value may be out of sync with the TestNotesMigration state. Work around this by always reopening the database, and ensuring the returned Provider<ReviewDb> caches it as well, whenever the state changes. Change-Id: I1bfbbf5492f8232028eba969ace53cc659cb8c8b
This commit is contained in:
committed by
Yuxuan 'fishy' Wang
parent
7baf0b546d
commit
96fe10508f
@@ -182,6 +182,14 @@ public class AcceptanceTestRequestScope {
|
||||
return old;
|
||||
}
|
||||
|
||||
public Context reopenDb() {
|
||||
// Setting a new context with the same fields is enough to get the ReviewDb
|
||||
// provider to reopen the database.
|
||||
Context old = current.get();
|
||||
return set(
|
||||
new Context(old.schemaFactory, old.session, old.user, old.created));
|
||||
}
|
||||
|
||||
/** Returns exactly one instance per command executed. */
|
||||
static final Scope REQUEST = new Scope() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user