Skip to content

Commit 93ee5a9

Browse files
committed
[tests] Check that BaseVM counts current snapshots
1 parent ed93217 commit 93ee5a9

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

Diff for: tests/test_base_virtual_machine.cpp

+29
Original file line numberDiff line numberDiff line change
@@ -317,4 +317,33 @@ TEST(BaseVMSnapshots, deletesSnapshots)
317317
vm.delete_snapshot("s1");
318318
EXPECT_EQ(vm.get_num_snapshots(), 0);
319319
}
320+
321+
TEST(BaseVMSnapshots, countsCurrentSnapshots)
322+
{
323+
const mp::VMSpecs specs{};
324+
MockBaseVirtualMachine vm{"mock-vm"};
325+
EXPECT_EQ(vm.get_num_snapshots(), 0);
326+
327+
auto snapshot = std::make_shared<MockSnapshot>();
328+
EXPECT_CALL(vm, make_specific_snapshot(_, _, _, _)).WillRepeatedly(Return(snapshot));
329+
EXPECT_CALL(*snapshot, capture).Times(AnyNumber());
330+
EXPECT_CALL(*snapshot, erase).Times(AnyNumber());
331+
332+
vm.take_snapshot(specs, "s1", "");
333+
EXPECT_EQ(vm.get_num_snapshots(), 1);
334+
335+
vm.take_snapshot(specs, "s2", "");
336+
vm.take_snapshot(specs, "s3", "");
337+
EXPECT_EQ(vm.get_num_snapshots(), 3);
338+
339+
vm.delete_snapshot("s1");
340+
EXPECT_EQ(vm.get_num_snapshots(), 2);
341+
342+
vm.delete_snapshot("s2");
343+
vm.delete_snapshot("s3");
344+
EXPECT_EQ(vm.get_num_snapshots(), 0);
345+
346+
vm.take_snapshot(specs, "s4", "");
347+
EXPECT_EQ(vm.get_num_snapshots(), 1);
348+
}
320349
} // namespace

0 commit comments

Comments
 (0)