|
GnuCash 2.4.99
|
00001 /*************************************************************************** 00002 * test-dbi.c 00003 * 00004 * Tests saving and loading to a dbi/sqlite3 db. The contents of an XML 00005 * file are read and saved to sqlite3, then the results read back and compared. 00006 * 00007 * Copyright (C) 2009 Phil Longstaff <plongstaff@rogers.com> 00008 ****************************************************************************/ 00009 00010 /* 00011 * This program is free software; you can redistribute it and/or modify 00012 * it under the terms of the GNU General Public License as published by 00013 * the Free Software Foundation; either version 2 of the License, or 00014 * (at your option) any later version. 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU General Public License 00022 * along with this program; if not, write to the Free Software 00023 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00024 * 02110-1301, USA. 00025 */ 00026 00027 #include "config.h" 00028 #include "qof.h" 00029 #include "cashobjects.h" 00030 #include "test-engine-stuff.h" 00031 #include "test-stuff.h" 00032 #include "test-dbi-stuff.h" 00033 00034 #include "TransLog.h" 00035 #include "Account.h" 00036 #include "Split.h" 00037 #include "gnc-commodity.h" 00038 00039 #define DBI_TEST_XML_FILENAME "test-dbi.xml" 00040 #define FILE_NAME "sqlite3:///tmp/test-sqlite3-file" 00041 #define GNC_LIB_NAME "gncmod-backend-dbi" 00042 00043 int main (int argc, char ** argv) 00044 { 00045 gchar* filename; 00046 QofSession* session_1; 00047 00048 qof_init(); 00049 cashobjects_register(); 00050 xaccLogDisable(); 00051 qof_load_backend_library ("../.libs/", GNC_LIB_NAME); 00052 00053 // Create a session with data 00054 session_1 = qof_session_new(); 00055 qof_session_begin( session_1, DBI_TEST_XML_FILENAME, FALSE, FALSE, FALSE ); 00056 qof_session_load( session_1, NULL ); 00057 00058 filename = tempnam( "/tmp", "test-sqlite3-" ); 00059 g_test_message ( "Using filename: %s\n", filename ); 00060 test_dbi_store_and_reload( "sqlite3", session_1, filename ); 00061 00062 g_test_message ( "TEST_MYSQL_URL='%s'\n", TEST_MYSQL_URL ); 00063 if ( strlen( TEST_MYSQL_URL ) > 0 ) 00064 { 00065 session_1 = qof_session_new(); 00066 qof_session_begin( session_1, DBI_TEST_XML_FILENAME, FALSE, FALSE, FALSE ); 00067 qof_session_load( session_1, NULL ); 00068 test_dbi_store_and_reload( "mysql", session_1, TEST_MYSQL_URL ); 00069 } 00070 00071 g_test_message ( "TEST_PGSQL_URL='%s'\n", TEST_PGSQL_URL ); 00072 if ( strlen( TEST_PGSQL_URL ) > 0 ) 00073 { 00074 session_1 = qof_session_new(); 00075 qof_session_begin( session_1, DBI_TEST_XML_FILENAME, FALSE, FALSE, FALSE ); 00076 qof_session_load( session_1, NULL ); 00077 test_dbi_store_and_reload( "pgsql", session_1, TEST_PGSQL_URL ); 00078 } 00079 print_test_results(); 00080 qof_close(); 00081 exit(get_rv()); 00082 }
1.7.4