mirror of
https://github.com/google/nomulus
synced 2026-09-18 22:14:23 +00:00
Add a dryrun flag to configure_tld command (#2188)
This will be used for presubmit testing.
This commit is contained in:
@@ -71,6 +71,11 @@ public class ConfigureTldCommand extends MutatingCommand {
|
|||||||
+ " configuration in the database.")
|
+ " configuration in the database.")
|
||||||
boolean breakglass;
|
boolean breakglass;
|
||||||
|
|
||||||
|
@Parameter(
|
||||||
|
names = {"-d", "--dryrun"},
|
||||||
|
description = "Does not execute the entity mutation")
|
||||||
|
boolean dryrun;
|
||||||
|
|
||||||
@Inject ObjectMapper mapper;
|
@Inject ObjectMapper mapper;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@@ -126,6 +131,9 @@ public class ConfigureTldCommand extends MutatingCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean dontRunCommand() {
|
protected boolean dontRunCommand() {
|
||||||
|
if (dryrun) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (!newDiff) {
|
if (!newDiff) {
|
||||||
if (oldTldInBreakglass && !breakglass) {
|
if (oldTldInBreakglass && !breakglass) {
|
||||||
// Run command to remove breakglass mode
|
// Run command to remove breakglass mode
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import com.google.common.io.Files;
|
|||||||
import com.google.common.testing.TestLogHandler;
|
import com.google.common.testing.TestLogHandler;
|
||||||
import google.registry.model.domain.token.AllocationToken;
|
import google.registry.model.domain.token.AllocationToken;
|
||||||
import google.registry.model.tld.Tld;
|
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.PremiumList;
|
||||||
import google.registry.model.tld.label.PremiumListDao;
|
import google.registry.model.tld.label.PremiumListDao;
|
||||||
import java.io.File;
|
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"
|
"Changes can not be applied since TLD is in breakglass mode but the breakglass flag"
|
||||||
+ " was not used");
|
+ " 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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user