[glom/glom-1-16] Fix the tests.



commit 2fd596e7efff3bc87be712cb3c74f37d1a6d390a
Author: Murray Cumming <murrayc murrayc com>
Date:   Sat Aug 7 13:01:42 2010 +0200

    Fix the tests.
    
    * tests/test_selfhosting_new_empty.cc:
    * tests/test_selfhosting_new_from_example.cc: Adapt to the recent
      change return type of ConnectionPool::startup().

 ChangeLog                                  |    8 ++++++
 tests/test_document_autosave.cc            |   18 +++++++-------
 tests/test_selfhosting_new_empty.cc        |    8 ++++-
 tests/test_selfhosting_new_from_example.cc |   37 +++++++++++++++-------------
 4 files changed, 43 insertions(+), 28 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 5ca4f4e..e796edc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2010-08-07  Murray Cumming  <murrayc murrayc com>
+
+	Fix the tests.
+
+	* tests/test_selfhosting_new_empty.cc:
+	* tests/test_selfhosting_new_from_example.cc: Adapt to the recent
+  change return type of ConnectionPool::startup().
+
 1.15.2:
 
 2010-08-06  Murray Cumming  <murrayc murrayc com>>
diff --git a/tests/test_document_autosave.cc b/tests/test_document_autosave.cc
index 796ea3e..7208237 100644
--- a/tests/test_document_autosave.cc
+++ b/tests/test_document_autosave.cc
@@ -38,12 +38,12 @@ void cleanup()
     if(ex.code() == Gio::Error::NOT_FOUND)
       return;
 
-    std::cerr << "Exception from Gio::File::remove(): " << ex.what();
+    std::cerr << G_STRFUNC << ": Exception from Gio::File::remove(): " << ex.what() << std::endl;
     exit(EXIT_FAILURE);
   }
   catch(const Glib::Error& ex)
   {
-    std::cerr << "Exception from Gio::File::remove(): " << ex.what();
+    std::cerr << G_STRFUNC << ":Exception from Gio::File::remove(): " << ex.what() << std::endl;
     exit(EXIT_FAILURE);
   }
 }
@@ -54,15 +54,15 @@ int main()
 
   //For instance, /tmp/testfile.glom");
   const std::string temp_filename = "testglom";
-  const std::string temp_filepath = Glib::build_filename(Glib::get_tmp_dir(), 
+  const std::string temp_filepath = Glib::build_filename(Glib::get_tmp_dir(),
     temp_filename);
   file_uri = Glib::filename_to_uri(temp_filepath);
-  
+
   //Make sure that the file does not exist yet:
   cleanup();
 
   const Glib::ustring test_title = "test_title";
-  
+
   //Test manual saving:
   {
     Glom::Document document;
@@ -78,7 +78,7 @@ int main()
     int failure_code = 0;
     const bool test = document.load(failure_code);
     g_assert(test);
-    
+
     g_assert( document.get_database_title() == test_title );
   }
 
@@ -99,12 +99,12 @@ int main()
     int failure_code = 0;
     const bool test = document.load(failure_code);
     g_assert(test);
-    
+
     g_assert( document.get_database_title() == test_title );
   }
-  
+
   cleanup();
-  
+
   Glom::libglom_deinit();
 
   return EXIT_SUCCESS;
diff --git a/tests/test_selfhosting_new_empty.cc b/tests/test_selfhosting_new_empty.cc
index ba7cac1..ed6905e 100644
--- a/tests/test_selfhosting_new_empty.cc
+++ b/tests/test_selfhosting_new_empty.cc
@@ -90,8 +90,12 @@ int main()
 
   //Start self-hosting:
   //TODO: Let this happen automatically on first connection?
-  const bool started = connection_pool->startup( sigc::ptr_fun(&on_startup_progress) );
-  g_assert(started);
+  const Glom::ConnectionPool::StartupErrors started = connection_pool->startup( sigc::ptr_fun(&on_startup_progress) );
+  if(started != Glom::ConnectionPool::Backend::STARTUPERROR_NONE)
+  {
+    std::cerr << "connection_pool->startup(): result=" << started << std::endl;
+  }
+  g_assert(started == Glom::ConnectionPool::Backend::STARTUPERROR_NONE);
 
   const bool stopped = connection_pool->cleanup( sigc::ptr_fun(&on_cleanup_progress) );
   g_assert(stopped);
diff --git a/tests/test_selfhosting_new_from_example.cc b/tests/test_selfhosting_new_from_example.cc
index 81cb508..d085587 100644
--- a/tests/test_selfhosting_new_from_example.cc
+++ b/tests/test_selfhosting_new_from_example.cc
@@ -57,7 +57,7 @@ static bool delete_directory(const Glib::RefPtr<Gio::File>& directory)
   //(Recursively) Delete any child files and directories,
   //so we can delete this directory.
   Glib::RefPtr<Gio::FileEnumerator> enumerator = directory->enumerate_children();
-  
+
   Glib::RefPtr<Gio::FileInfo> info = enumerator->next_file();
   while(info)
   {
@@ -70,14 +70,14 @@ static bool delete_directory(const Glib::RefPtr<Gio::File>& directory)
 
     if(!removed_child)
        return false;
-    
+
     info = enumerator->next_file();
   }
 
   //Delete the actual directory:
   if(!directory->remove())
     return false;
-  
+
   return true;
 }
 
@@ -95,8 +95,8 @@ std::string temp_filepath_dir;
 void cleanup()
 {
   Glom::ConnectionPool* connection_pool = Glom::ConnectionPool::get_instance();
- 
-  const bool stopped = connection_pool->cleanup( sigc::ptr_fun(&on_cleanup_progress) );  
+
+  const bool stopped = connection_pool->cleanup( sigc::ptr_fun(&on_cleanup_progress) );
   g_assert(stopped);
 
   //Make sure the directory is removed at the end,
@@ -116,8 +116,8 @@ int main()
   #ifdef GLIBMM_EXCEPTIONS_ENABLED
   try
   {
-    const std::string path = 
-       Glib::build_filename(GLOM_DOCDIR_EXAMPLES_NOTINSTALLED, 
+    const std::string path =
+       Glib::build_filename(GLOM_DOCDIR_EXAMPLES_NOTINSTALLED,
          "example_music_collection.glom");
     uri = Glib::filename_to_uri(path);
   }
@@ -146,18 +146,18 @@ int main()
     std::cerr << "Document::load() failed with failure_code=" << failure_code << std::endl;
     return EXIT_FAILURE;
   }
-  
+
   g_assert(document.get_is_example_file());;
 
   Glom::ConnectionPool* connection_pool = Glom::ConnectionPool::get_instance();
-  
+
   //Save a copy, specifying the path to file in a directory:
   //For instance, /tmp/testfileglom/testfile.glom");
   const std::string temp_filename = "testglom";
-  temp_filepath_dir = Glib::build_filename(Glib::get_tmp_dir(), 
+  temp_filepath_dir = Glib::build_filename(Glib::get_tmp_dir(),
     temp_filename);
   const std::string temp_filepath = Glib::build_filename(temp_filepath_dir, temp_filename);
-  
+
   //Make sure that the file does not exist yet:
   {
     const Glib::ustring uri = Glib::filename_to_uri(temp_filepath_dir);
@@ -167,7 +167,7 @@ int main()
   //Save the example as a real file:
   const Glib::ustring file_uri = Glib::filename_to_uri(temp_filepath);
   document.set_file_uri(file_uri);
-  
+
   document.set_hosting_mode(Glom::Document::HOSTING_MODE_POSTGRES_SELF);
   document.set_is_example_file(false);
   document.set_network_shared(false);
@@ -184,16 +184,19 @@ int main()
   connection_pool->set_password(password);
 
   //Create the self-hosting files:
-  const Glom::ConnectionPool::InitErrors initialized_errors = 
+  const Glom::ConnectionPool::InitErrors initialized_errors =
     connection_pool->initialize( sigc::ptr_fun(&on_initialize_progress) );
   g_assert(initialized_errors == Glom::ConnectionPool::Backend::INITERROR_NONE);
 
   //Start self-hosting:
   //TODO: Let this happen automatically on first connection?
-  const bool started = connection_pool->startup( sigc::ptr_fun(&on_startup_progress) );
-  if(!started)
+  const Glom::ConnectionPool::StartupErrors started = connection_pool->startup( sigc::ptr_fun(&on_startup_progress) );
+  if(started != Glom::ConnectionPool::Backend::STARTUPERROR_NONE)
+  {
+    std::cerr << "connection_pool->startup(): result=" << started << std::endl;
     cleanup();
-  g_assert(started);
+  }
+  g_assert(started == Glom::ConnectionPool::Backend::STARTUPERROR_NONE);
 
   const bool recreated = Glom::DbUtils::recreate_database_from_document(&document, sigc::ptr_fun(&on_recreate_progress) );
   if(!recreated)
@@ -201,7 +204,7 @@ int main()
   g_assert(recreated);
 
   cleanup();
-  
+
   Glom::libglom_deinit();
 
   return EXIT_SUCCESS;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]