Skip to content

Commit

Permalink
[tests] Check that BaseVM counts current snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
ricab committed Dec 7, 2023
1 parent ed93217 commit 93ee5a9
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/test_base_virtual_machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,4 +317,33 @@ TEST(BaseVMSnapshots, deletesSnapshots)
vm.delete_snapshot("s1");
EXPECT_EQ(vm.get_num_snapshots(), 0);
}

TEST(BaseVMSnapshots, countsCurrentSnapshots)
{
const mp::VMSpecs specs{};
MockBaseVirtualMachine vm{"mock-vm"};
EXPECT_EQ(vm.get_num_snapshots(), 0);

auto snapshot = std::make_shared<MockSnapshot>();
EXPECT_CALL(vm, make_specific_snapshot(_, _, _, _)).WillRepeatedly(Return(snapshot));
EXPECT_CALL(*snapshot, capture).Times(AnyNumber());
EXPECT_CALL(*snapshot, erase).Times(AnyNumber());

vm.take_snapshot(specs, "s1", "");
EXPECT_EQ(vm.get_num_snapshots(), 1);

vm.take_snapshot(specs, "s2", "");
vm.take_snapshot(specs, "s3", "");
EXPECT_EQ(vm.get_num_snapshots(), 3);

vm.delete_snapshot("s1");
EXPECT_EQ(vm.get_num_snapshots(), 2);

vm.delete_snapshot("s2");
vm.delete_snapshot("s3");
EXPECT_EQ(vm.get_num_snapshots(), 0);

vm.take_snapshot(specs, "s4", "");
EXPECT_EQ(vm.get_num_snapshots(), 1);
}
} // namespace

0 comments on commit 93ee5a9

Please sign in to comment.