1
0
mirror of https://github.com/google/nomulus synced 2026-01-05 04:56:03 +00:00

Add better assertions on registry_tool stdout

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=127561648
This commit is contained in:
mcilwain
2016-07-15 11:38:50 -07:00
committed by Ben McIlwain
parent bca9b2a806
commit 60180348cd

View File

@@ -145,17 +145,22 @@ public abstract class CommandTestCase<C extends Command> {
return ofy().load().type(PollMessage.class).count();
}
protected void assertStdoutIs(String expected) throws Exception {
assertThat(getStdoutAsString()).isEqualTo(expected);
}
protected void assertInStdout(String... expected) throws Exception {
String stdout = getStdoutAsString();
for (String line : expected) {
assertThat(stdout.toString(UTF_8.toString())).contains(line);
assertThat(stdout).contains(line);
}
}
void assertNotInStdout(String expected) throws Exception {
assertThat(stdout.toString(UTF_8.toString())).doesNotContain(expected);
assertThat(getStdoutAsString()).doesNotContain(expected);
}
String getStdoutAsString() {
protected String getStdoutAsString() {
return new String(stdout.toByteArray(), UTF_8);
}