diff options
author | Marco Bubke <marco.bubke@qt.io> | 2018-03-28 16:25:01 +0200 |
---|---|---|
committer | Marco Bubke <marco.bubke@qt.io> | 2018-04-04 13:35:06 +0000 |
commit | 5870905db6588121e259d0927de35e838dd2df7e (patch) | |
tree | 19ffd12bf7de1a670cd00b44a7a4fd559de921c0 /tests/unit/unittest/precompiledheaderstorage-test.cpp | |
parent | 789379a8e3321d37c76fc72f7682d92d2e30f871 (diff) | |
download | qt-creator-5870905db6588121e259d0927de35e838dd2df7e.tar.gz |
Clang: Handle a busy database in the PCH plugin
This can be always happen for write statements. It fixes the wrong behavior
of the transaction that it tried to rollback if begin fails. If begin fails
the transaction never started so there is nothing to rollback.
Change-Id: I8a03162257fa22a0bb66ccb844f90c6afbc7db64
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Diffstat (limited to 'tests/unit/unittest/precompiledheaderstorage-test.cpp')
-rw-r--r-- | tests/unit/unittest/precompiledheaderstorage-test.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/unit/unittest/precompiledheaderstorage-test.cpp b/tests/unit/unittest/precompiledheaderstorage-test.cpp index 2871e3fd11..86f46156cf 100644 --- a/tests/unit/unittest/precompiledheaderstorage-test.cpp +++ b/tests/unit/unittest/precompiledheaderstorage-test.cpp @@ -30,6 +30,7 @@ #include <refactoringdatabaseinitializer.h> #include <sqlitedatabase.h> #include <sqlitewritestatement.h> +#include <sqlitetransaction.h> namespace { @@ -59,11 +60,29 @@ TEST_F(PrecompiledHeaderStorage, InsertPrecompiledHeader) { InSequence s; + EXPECT_CALL(database, immediateBegin()); + EXPECT_CALL(insertProjectPartStatement, write(TypedEq<Utils::SmallStringView>("project1"))); + EXPECT_CALL(insertPrecompiledHeaderStatement, + write(TypedEq<Utils::SmallStringView>("project1"), + TypedEq<Utils::SmallStringView>("/path/to/pch"), + TypedEq<long long>(22))); + EXPECT_CALL(database, commit()); + + storage.insertPrecompiledHeader("project1", "/path/to/pch", 22); +} + +TEST_F(PrecompiledHeaderStorage, InsertPrecompiledHeaderStatementIsBusy) +{ + InSequence s; + + EXPECT_CALL(database, immediateBegin()).WillOnce(Throw(Sqlite::StatementIsBusy("busy"))); + EXPECT_CALL(database, immediateBegin()); EXPECT_CALL(insertProjectPartStatement, write(TypedEq<Utils::SmallStringView>("project1"))); EXPECT_CALL(insertPrecompiledHeaderStatement, write(TypedEq<Utils::SmallStringView>("project1"), TypedEq<Utils::SmallStringView>("/path/to/pch"), TypedEq<long long>(22))); + EXPECT_CALL(database, commit()); storage.insertPrecompiledHeader("project1", "/path/to/pch", 22); } @@ -72,7 +91,21 @@ TEST_F(PrecompiledHeaderStorage, DeletePrecompiledHeader) { InSequence s; + EXPECT_CALL(database, immediateBegin()); + EXPECT_CALL(deletePrecompiledHeaderStatement, write(TypedEq<Utils::SmallStringView>("project1"))); + EXPECT_CALL(database, commit()); + + storage.deletePrecompiledHeader("project1"); +} + +TEST_F(PrecompiledHeaderStorage, DeletePrecompiledHeaderStatementIsBusy) +{ + InSequence s; + + EXPECT_CALL(database, immediateBegin()).WillOnce(Throw(Sqlite::StatementIsBusy("busy"))); + EXPECT_CALL(database, immediateBegin()); EXPECT_CALL(deletePrecompiledHeaderStatement, write(TypedEq<Utils::SmallStringView>("project1"))); + EXPECT_CALL(database, commit()); storage.deletePrecompiledHeader("project1"); } |