mirror of
https://github.com/google/nomulus.git
synced 2025-07-23 19:20:44 +02:00
Add a dryrun flag to configure_tld command (#2188)
This will be used for presubmit testing.
This commit is contained in:
parent
16e5018489
commit
8f8ffe7020
2 changed files with 28 additions and 0 deletions
|
@ -71,6 +71,11 @@ public class ConfigureTldCommand extends MutatingCommand {
|
|||
+ " configuration in the database.")
|
||||
boolean breakglass;
|
||||
|
||||
@Parameter(
|
||||
names = {"-d", "--dryrun"},
|
||||
description = "Does not execute the entity mutation")
|
||||
boolean dryrun;
|
||||
|
||||
@Inject ObjectMapper mapper;
|
||||
|
||||
@Inject
|
||||
|
@ -126,6 +131,9 @@ public class ConfigureTldCommand extends MutatingCommand {
|
|||
|
||||
@Override
|
||||
protected boolean dontRunCommand() {
|
||||
if (dryrun) {
|
||||
return true;
|
||||
}
|
||||
if (!newDiff) {
|
||||
if (oldTldInBreakglass && !breakglass) {
|
||||
// Run command to remove breakglass mode
|
||||
|
|
|
@ -41,6 +41,7 @@ import com.google.common.io.Files;
|
|||
import com.google.common.testing.TestLogHandler;
|
||||
import google.registry.model.domain.token.AllocationToken;
|
||||
import google.registry.model.tld.Tld;
|
||||
import google.registry.model.tld.Tld.TldNotFoundException;
|
||||
import google.registry.model.tld.label.PremiumList;
|
||||
import google.registry.model.tld.label.PremiumListDao;
|
||||
import java.io.File;
|
||||
|
@ -570,4 +571,23 @@ public class ConfigureTldCommandTest extends CommandTestCase<ConfigureTldCommand
|
|||
"Changes can not be applied since TLD is in breakglass mode but the breakglass flag"
|
||||
+ " was not used");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_dryRunOnCreate_noChanges() throws Exception {
|
||||
File tldFile = tmpDir.resolve("tld.yaml").toFile();
|
||||
Files.asCharSink(tldFile, UTF_8).write(loadFile(getClass(), "tld.yaml"));
|
||||
runCommandForced("--input=" + tldFile, "--dryrun");
|
||||
assertThrows(TldNotFoundException.class, () -> Tld.get("tld"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_dryRunOnUpdate_noChanges() throws Exception {
|
||||
Tld tld = createTld("tld");
|
||||
assertThat(tld.getCreateBillingCost()).isEqualTo(Money.of(USD, 13));
|
||||
File tldFile = tmpDir.resolve("tld.yaml").toFile();
|
||||
Files.asCharSink(tldFile, UTF_8).write(loadFile(getClass(), "tld.yaml"));
|
||||
runCommandForced("--input=" + tldFile, "-d");
|
||||
Tld notUpdatedTld = Tld.get("tld");
|
||||
assertThat(notUpdatedTld.getCreateBillingCost()).isEqualTo(Money.of(USD, 13));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue