mirror of
https://github.com/google/nomulus.git
synced 2025-05-17 09:57:17 +02:00
Always clear ofy session cache in command tests
The previous code would not execute after failure tests that ended with thrown exceptions, potentially causing issues with post-run verification inside of tests. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=117484219
This commit is contained in:
parent
99a50f7972
commit
14c794aa45
1 changed files with 10 additions and 7 deletions
|
@ -76,14 +76,17 @@ public abstract class CommandTestCase<C extends Command> {
|
||||||
|
|
||||||
void runCommand(String... args) throws Exception {
|
void runCommand(String... args) throws Exception {
|
||||||
RegistryToolEnvironment.UNITTEST.setup();
|
RegistryToolEnvironment.UNITTEST.setup();
|
||||||
|
try {
|
||||||
JCommander jcommander = new JCommander(command);
|
JCommander jcommander = new JCommander(command);
|
||||||
jcommander.addConverterFactory(new ParameterFactory());
|
jcommander.addConverterFactory(new ParameterFactory());
|
||||||
jcommander.parse(args);
|
jcommander.parse(args);
|
||||||
command.run();
|
command.run();
|
||||||
|
} finally {
|
||||||
// Clear the session cache so that subsequent reads for verification purposes hit datastore.
|
// Clear the session cache so that subsequent reads for verification purposes hit datastore.
|
||||||
// This primarily matters for AutoTimestamp fields, which otherwise won't have updated values.
|
// This primarily matters for AutoTimestamp fields, which otherwise won't have updated values.
|
||||||
ofy().clearSessionCache();
|
ofy().clearSessionCache();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Adds "--force" as the first parameter, then runs the command. */
|
/** Adds "--force" as the first parameter, then runs the command. */
|
||||||
void runCommandForced(String... args) throws Exception {
|
void runCommandForced(String... args) throws Exception {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue