Fix command tests that set stdout/stderr (#258)

* Fix command tests that set stdout/stderr

CommandTestCase already wraps stdout stderr, just use the provided methods.
This commit is contained in:
Michael Muller 2019-09-09 09:12:48 -04:00 committed by GitHub
parent 729b69550e
commit c5e4e862bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 12 deletions

View file

@ -34,8 +34,6 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Range;
import com.googlecode.objectify.Key;
import google.registry.model.registry.Registry;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.math.BigDecimal;
import org.joda.money.Money;
import org.joda.time.DateTime;
@ -472,14 +470,11 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
@Test
public void testSuccess_setCommonAndReservedListFromOtherTld_withOverride() throws Exception {
ByteArrayOutputStream errContent = new ByteArrayOutputStream();
System.setErr(new PrintStream(errContent));
runReservedListsTestOverride("common_abuse,tld_banned");
String errMsg =
"Error overridden: The reserved list(s) tld_banned "
+ "cannot be applied to the tld xn--q9jyb4c";
assertThat(errContent.toString()).contains(errMsg);
System.setOut(null);
assertThat(getStderrAsString()).contains(errMsg);
}
@Test

View file

@ -38,8 +38,6 @@ import com.google.common.collect.ImmutableSortedMap;
import com.googlecode.objectify.Key;
import google.registry.model.registry.Registry;
import google.registry.model.registry.label.PremiumList;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import org.joda.money.Money;
import org.joda.time.DateTime;
import org.joda.time.Duration;
@ -898,14 +896,11 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
@Test
public void testSuccess_setCommonAndReservedListFromOtherTld_withOverride() throws Exception {
ByteArrayOutputStream errContent = new ByteArrayOutputStream();
System.setErr(new PrintStream(errContent));
runReservedListsTestOverride("common_abuse,tld_banned");
String errMsg =
"Error overridden: The reserved list(s) tld_banned "
+ "cannot be applied to the tld xn--q9jyb4c";
assertThat(errContent.toString()).contains(errMsg);
System.setOut(null);
assertThat(getStderrAsString()).contains(errMsg);
}
@Test