[glom] Fix the tests.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] Fix the tests.
- Date: Mon, 9 Aug 2010 00:22:42 +0000 (UTC)
commit 39bd6c87f626c565c35078b013c22c720380984e
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 d60b4c1..cc47f7a 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().
+
2010-08-06 Murray Cumming <murrayc murrayc com>>
FieldFormatting: Default to show-all for related choices.
diff --git a/tests/test_document_autosave.cc b/tests/test_document_autosave.cc
index 7502466..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 << G_STRFUNC << ": " << 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 << G_STRFUNC << ": " << 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 fc84fc7..40b47f5 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,
@@ -115,8 +115,8 @@ int main()
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);
}
@@ -141,18 +141,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);
@@ -162,7 +162,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);
@@ -179,16 +179,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)
@@ -196,7 +199,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]