Skip to content

Commit

Permalink
Add non regression tests for getAllocatedSize and getVHDInfo allocated
Browse files Browse the repository at this point in the history
size

Signed-off-by: Damien Thenot <damien.thenot@vates.tech>
  • Loading branch information
Nambrok committed Nov 28, 2024
1 parent 010ed5a commit ba5e783
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/test_vhdutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,3 +362,43 @@ def test_function(args, inp):

# Act/Assert
self.assertEqual(25, vhdutil.coalesce(TEST_VHD_PATH))

@testlib.with_context
def test_get_vhd_info_allocated_size(self, context):
"""
Test that vhdutil.getVHDInfo return the allocated size in byte
"""
# Arrange
def test_function(args, inp):
return 0, "51200\n39621239296\nd90f890c-d173-4eaf-ba09-fc2d6e50f6c0.vhd has no parent\nhidden: 0\n18856", ""

context.add_executable(VHD_UTIL, test_function)
import FileSR
vhdinfo = vhdutil.getVHDInfo(TEST_VHD_PATH, FileSR.FileVDI.extractUuid)

# Act/Assert
self.assertEqual(18856*2*1024*1024 , vhdinfo.sizeAllocated)

@testlib.with_context
def test_get_allocated_size(self, context):
"""
Test that vhdutil.getAllocatedSize return the size in byte
"""
# Arrange
call_args = None
def test_function(args, inp):
nonlocal call_args
call_args = args
return 0, b"18856", b""

context.add_executable(VHD_UTIL, test_function)

# Act
result = vhdutil.getAllocatedSize(TEST_VHD_NAME)

# Assert
self.assertEqual(18856*2*1024*1024, result)
self.assertEqual(
[VHD_UTIL, "query", "--debug", "-a",
"-n", TEST_VHD_NAME],
call_args)

0 comments on commit ba5e783

Please sign in to comment.