Author: dmacvicar Date: Tue Jul 10 21:03:38 2007 New Revision: 5962 URL: http://svn.opensuse.org/viewcvs/zypp?rev=5962&view=rev Log: add test to see wether we clean up the cache properly when cleaning a repository. Not passed yet :-) yes tests are good Modified: branches/REFACTORING-10_3/libzypp/tests/cache/CacheStore_test.cc Modified: branches/REFACTORING-10_3/libzypp/tests/cache/CacheStore_test.cc URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp/tests/cache/CacheStore_test.cc?rev=5962&r1=5961&r2=5962&view=diff ============================================================================== --- branches/REFACTORING-10_3/libzypp/tests/cache/CacheStore_test.cc (original) +++ branches/REFACTORING-10_3/libzypp/tests/cache/CacheStore_test.cc Tue Jul 10 21:03:38 2007 @@ -30,6 +30,7 @@ using namespace zypp::repo; using namespace zypp::repo::cached; using namespace boost::unit_test; +using namespace sqlite3x; void cache_write_test(const string &dir) { @@ -96,6 +97,41 @@ MIL << dbres.size() << " resolvables" << endl; } + + // now clean the repo and check everything is clean + { + cache::CacheStore store(tmpdir.path()); + repository_id = store.lookupOrAppendRepository("novell.com"); + store.cleanRepository(repository_id); + store.commit(); + } + { + sqlite3_connection con((tmpdir.path() + "zypp.db").c_str()); + int count; + + sqlite3_command tables_cmd( con, "select name from sqlite_master where type='table';"); + sqlite3_reader reader = tables_cmd.executereader(); + list<string> tables; + while ( reader.read() ) + { + string tablename = reader.getstring(0); + if ( tablename != "sqlite_sequence" ) + tables.push_back(tablename); + } + reader.close(); + + for ( list<string>::const_iterator it = tables.begin(); + it != tables.end(); + ++it ) + { + MIL << "Checking table " << *it << endl; + string query = (string("select count(*) from ") + (*it) +";"); + sqlite3_command cmd(con, query.c_str()); + count = cmd.executeint(); + string msg = (string("there should be no ") + (*it) +" after cleaning"); + BOOST_CHECK_MESSAGE( count == 0, msg.c_str()); + } + } } test_suite* @@ -118,7 +154,7 @@ test_suite* test= BOOST_TEST_SUITE("CacheStore"); std::string const params[] = { datadir }; - test->add(BOOST_PARAM_TEST_CASE(&cache_write_test, + test->add(BOOST_PARAM_TEST_CASE(&cache_write_test2, (std::string const*)params, params+1)); //test->add(BOOST_PARAM_TEST_CASE(&cache_write_test2, // (std::string const*)params, params+1)); -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org