mirror of
https://github.com/google/nomulus
synced 2026-01-04 04:04:22 +00: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:
@@ -76,13 +76,16 @@ public abstract class CommandTestCase<C extends Command> {
|
||||
|
||||
void runCommand(String... args) throws Exception {
|
||||
RegistryToolEnvironment.UNITTEST.setup();
|
||||
JCommander jcommander = new JCommander(command);
|
||||
jcommander.addConverterFactory(new ParameterFactory());
|
||||
jcommander.parse(args);
|
||||
command.run();
|
||||
// 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.
|
||||
ofy().clearSessionCache();
|
||||
try {
|
||||
JCommander jcommander = new JCommander(command);
|
||||
jcommander.addConverterFactory(new ParameterFactory());
|
||||
jcommander.parse(args);
|
||||
command.run();
|
||||
} finally {
|
||||
// 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.
|
||||
ofy().clearSessionCache();
|
||||
}
|
||||
}
|
||||
|
||||
/** Adds "--force" as the first parameter, then runs the command. */
|
||||
|
||||
Reference in New Issue
Block a user