ChangeIT: Extend tests of the abandon and restore APIs
Add tests that a resource conflict response is returned when attempting to abandon a change that is - Already abandoned - A draft change and when attempting to restore a change that is not abandoned. Change-Id: I7c844769419d12ebb3c01ba5d43f36bc3a3e9520
This commit is contained in:
@@ -137,32 +137,59 @@ public class ChangeIT extends AbstractDaemonTest {
|
|||||||
@Test
|
@Test
|
||||||
public void abandon() throws Exception {
|
public void abandon() throws Exception {
|
||||||
PushOneCommit.Result r = createChange();
|
PushOneCommit.Result r = createChange();
|
||||||
assertThat(info(r.getChangeId()).status).isEqualTo(ChangeStatus.NEW);
|
String changeId = r.getChangeId();
|
||||||
|
assertThat(info(changeId).status).isEqualTo(ChangeStatus.NEW);
|
||||||
gApi.changes()
|
gApi.changes()
|
||||||
.id(r.getChangeId())
|
.id(changeId)
|
||||||
.abandon();
|
.abandon();
|
||||||
ChangeInfo info = get(r.getChangeId());
|
ChangeInfo info = get(changeId);
|
||||||
assertThat(info.status).isEqualTo(ChangeStatus.ABANDONED);
|
assertThat(info.status).isEqualTo(ChangeStatus.ABANDONED);
|
||||||
assertThat(Iterables.getLast(info.messages).message.toLowerCase())
|
assertThat(Iterables.getLast(info.messages).message.toLowerCase())
|
||||||
.contains("abandoned");
|
.contains("abandoned");
|
||||||
|
|
||||||
|
exception.expect(ResourceConflictException.class);
|
||||||
|
exception.expectMessage("change is abandoned");
|
||||||
|
gApi.changes()
|
||||||
|
.id(changeId)
|
||||||
|
.abandon();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void abandonDraft() throws Exception {
|
||||||
|
PushOneCommit.Result r = createDraftChange();
|
||||||
|
String changeId = r.getChangeId();
|
||||||
|
assertThat(info(changeId).status).isEqualTo(ChangeStatus.DRAFT);
|
||||||
|
|
||||||
|
exception.expect(ResourceConflictException.class);
|
||||||
|
exception.expectMessage("draft changes cannot be abandoned");
|
||||||
|
gApi.changes()
|
||||||
|
.id(changeId)
|
||||||
|
.abandon();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void restore() throws Exception {
|
public void restore() throws Exception {
|
||||||
PushOneCommit.Result r = createChange();
|
PushOneCommit.Result r = createChange();
|
||||||
assertThat(info(r.getChangeId()).status).isEqualTo(ChangeStatus.NEW);
|
String changeId = r.getChangeId();
|
||||||
|
assertThat(info(changeId).status).isEqualTo(ChangeStatus.NEW);
|
||||||
gApi.changes()
|
gApi.changes()
|
||||||
.id(r.getChangeId())
|
.id(changeId)
|
||||||
.abandon();
|
.abandon();
|
||||||
assertThat(info(r.getChangeId()).status).isEqualTo(ChangeStatus.ABANDONED);
|
assertThat(info(changeId).status).isEqualTo(ChangeStatus.ABANDONED);
|
||||||
|
|
||||||
gApi.changes()
|
gApi.changes()
|
||||||
.id(r.getChangeId())
|
.id(changeId)
|
||||||
.restore();
|
.restore();
|
||||||
ChangeInfo info = get(r.getChangeId());
|
ChangeInfo info = get(changeId);
|
||||||
assertThat(info.status).isEqualTo(ChangeStatus.NEW);
|
assertThat(info.status).isEqualTo(ChangeStatus.NEW);
|
||||||
assertThat(Iterables.getLast(info.messages).message.toLowerCase())
|
assertThat(Iterables.getLast(info.messages).message.toLowerCase())
|
||||||
.contains("restored");
|
.contains("restored");
|
||||||
|
|
||||||
|
exception.expect(ResourceConflictException.class);
|
||||||
|
exception.expectMessage("change is new");
|
||||||
|
gApi.changes()
|
||||||
|
.id(changeId)
|
||||||
|
.restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user