Skip to content

Commit e92f38e

Browse files
committed
resizevolume: add unit test for Allocated volume
1 parent ae6acc1 commit e92f38e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

server/src/test/java/com/cloud/storage/VolumeApiServiceImplTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1911,4 +1911,21 @@ public void testResizeVolumeWithoutEnoughCapacity() throws ResourceAllocationExc
19111911
verify(volumeServiceMock).resize(any(VolumeInfo.class));
19121912
}
19131913
}
1914+
1915+
@Test
1916+
public void testResizeVolumeInAllocateState() throws ResourceAllocationException, ExecutionException, InterruptedException {
1917+
ResizeVolumeCmd cmd = new ResizeVolumeCmd();
1918+
ReflectionTestUtils.setField(cmd, "id", volumeMockId);
1919+
ReflectionTestUtils.setField(cmd, "newDiskOfferingId", newDiskOfferingMockId);
1920+
1921+
testResizeVolumeSetup();
1922+
1923+
when(volumeVoMock.getState()).thenReturn(Volume.State.Allocated);
1924+
1925+
try (MockedStatic<UsageEventUtils> ignored = Mockito.mockStatic(UsageEventUtils.class)) {
1926+
volumeApiServiceImpl.resizeVolume(cmd);
1927+
1928+
verify(volumeServiceMock, times(0)).resize(any(VolumeInfo.class));
1929+
}
1930+
}
19141931
}

0 commit comments

Comments
 (0)