Skip to content

Commit

Permalink
[tests] Check null head after capture failure
Browse files Browse the repository at this point in the history
  • Loading branch information
ricab committed Jan 5, 2024
1 parent 9be8cfd commit fe8313c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/test_base_virtual_machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -940,4 +940,17 @@ TEST_F(BaseVM, snapshotDeletionKeepsHeadOnFailure)
EXPECT_EQ(vm.take_snapshot(specs, "", "")->get_parent().get(), snapshot_album[1].get());
}

TEST_F(BaseVM, takeSnapshotRevertsToNullHeadOnFirstFailure)
{
auto snapshot = std::make_shared<NiceMock<MockSnapshot>>();
EXPECT_CALL(*snapshot, capture).WillOnce(Throw(std::runtime_error{"intentional"}));
EXPECT_CALL(vm, make_specific_snapshot(_, _, _, _)).WillOnce(Return(snapshot)).RetiresOnSaturation();

mp::VMSpecs specs{};
EXPECT_ANY_THROW(vm.take_snapshot(specs, "", ""));

mock_snapshotting();
EXPECT_EQ(vm.take_snapshot(specs, "", "")->get_parent().get(), nullptr);
}

} // namespace

0 comments on commit fe8313c

Please sign in to comment.