Bug 796878 - test-qofsession fails on x86_32.

This commit is contained in:
John Ralls 2018-10-04 15:44:32 -07:00
parent a8c884016e
commit 7a4b06c442
2 changed files with 11 additions and 8 deletions

View File

@ -225,8 +225,9 @@ QofSessionImpl::load (QofPercentageFunc percentage_func) noexcept
(err != ERR_SQL_DB_TOO_OLD) && (err != ERR_SQL_DB_TOO_OLD) &&
(err != ERR_SQL_DB_TOO_NEW)) (err != ERR_SQL_DB_TOO_NEW))
{ {
qof_book_destroy(m_book); auto old_book = m_book;
m_book = qof_book_new(); m_book = qof_book_new();
qof_book_destroy(old_book);
LEAVE ("error from backend %d", get_error ()); LEAVE ("error from backend %d", get_error ());
return; return;
} }

View File

@ -170,20 +170,22 @@ TEST (QofSessionTest, clear_error)
TEST (QofSessionTest, load) TEST (QofSessionTest, load)
{ {
// We register a provider that gives a backend that /* We register a provider that gives a backend that throws an error on load.
// throws an error on load. * This error during load should cause the qof session to destroy the book
// This error during load should cause the qof session to * and create a new one.
// "roll back" the book load. */
qof_backend_register_provider (get_provider ()); qof_backend_register_provider (get_provider ());
QofSession s; QofSession s;
s.begin ("book1", false, false, false); s.begin ("book1", false, false, false);
auto book = s.get_book (); auto book = s.get_book ();
s.load (nullptr); s.load (nullptr);
EXPECT_EQ (book, s.get_book ()); EXPECT_NE (book, s.get_book ());
// Now we'll do the load without returning an error from the backend, /* Now we'll do the load without returning an error from the backend,
// and ensure that it's the original book and that it's not empty. * and ensure that it's the new book from the previous test.
*/
load_error = false; load_error = false;
book = s.get_book();
s.load (nullptr); s.load (nullptr);
EXPECT_EQ (book, s.get_book ()); EXPECT_EQ (book, s.get_book ());
EXPECT_EQ (s.get_error(), ERR_BACKEND_NO_ERR); EXPECT_EQ (s.get_error(), ERR_BACKEND_NO_ERR);