PushOneCommit: Add assertions against null ref update result

Change-Id: I541f4cf59d374a8114e4c127b478b2fea5cbe30b
This commit is contained in:
David Pursehouse 2017-10-20 13:27:25 +09:00
parent f113d8aa95
commit 202f8f3c5d

View File

@ -416,6 +416,7 @@ public class PushOneCommit {
public void assertErrorStatus() {
RemoteRefUpdate refUpdate = result.getRemoteUpdate(ref);
assertThat(refUpdate).isNotNull();
assertThat(refUpdate.getStatus())
.named(message(refUpdate))
.isEqualTo(Status.REJECTED_OTHER_REASON);
@ -423,17 +424,20 @@ public class PushOneCommit {
private void assertStatus(Status expectedStatus, String expectedMessage) {
RemoteRefUpdate refUpdate = result.getRemoteUpdate(ref);
assertThat(refUpdate).isNotNull();
assertThat(refUpdate.getStatus()).named(message(refUpdate)).isEqualTo(expectedStatus);
assertThat(refUpdate.getMessage()).isEqualTo(expectedMessage);
}
public void assertMessage(String expectedMessage) {
RemoteRefUpdate refUpdate = result.getRemoteUpdate(ref);
assertThat(refUpdate).isNotNull();
assertThat(message(refUpdate).toLowerCase()).contains(expectedMessage.toLowerCase());
}
public String getMessage() {
RemoteRefUpdate refUpdate = result.getRemoteUpdate(ref);
assertThat(refUpdate).isNotNull();
return message(refUpdate);
}