}
*/
+#if 0
+BOOST_AUTO_TEST_CASE(pool_query_recovery)
+{
+ Pathname testfile(TESTS_SRC_DIR);
+ testfile += "/zypp/data/PoolQuery/savedqueries";
+ cout << "****recovery****" << endl;
+ std::vector<PoolQuery> queries;
+ std::insert_iterator<std::vector<PoolQuery> > ii( queries,queries.begin());
+ readPoolQueriesFromFile(testfile,ii);
+ BOOST_REQUIRE_MESSAGE(queries.size()==1,"Bad count of readed queries.");
+ cout << queries[0].asString() << endl;
+ BOOST_CHECK(queries[0].size() == 8);
+}
+
+#endif
+
// test matching
BOOST_AUTO_TEST_CASE(pool_query_equal)
{
BOOST_CHECK(q==q4);
BOOST_CHECK(q4!=q3);
}
-
-// save/load query
-BOOST_AUTO_TEST_CASE(pool_query_save_restore)
-{
-#warning CAN NOT USE A FIX SOLV FILE
-// must store some raw metadata and generate the solv file
-// otherwise trestcases break whenever the solv format changes
-#if 0
- Pathname dir(TESTS_SRC_DIR);
- dir += "/zypp/data/PoolQuery";
-
- ZYpp::Ptr z = getZYpp();
-
- sat::Pool::instance().addRepoSolv(dir + "foo.solv");
-
- PoolQuery query;
- //query.setInstalledOnly();
- query.execute("kde", &result_cb);
-
- cout << "search done." << endl;
-
- query.setMatchExact(true);
- query.execute("kde", &result_cb);
-
- cout << "search done." << endl;
-#endif
-
-//test recovery from file
- Pathname pathToQueries(TESTS_SRC_DIR);
- pathToQueries += "/zypp/data/PoolQuery/savedqueries";
-
- std::list<PoolQuery> savedQueries;
-
- std::insert_iterator<std::list<PoolQuery> > ii(savedQueries, savedQueries.end());
- readPoolQueriesFromFile(pathToQueries,ii);
- BOOST_CHECK( savedQueries.size() == 2 );
-
- filesystem::TmpFile tmp;
- Pathname tmpPath = tmp.path();
-
- savedQueries.clear();
-
- PoolQuery q1;
- PoolQuery q2;
-
- q1.addKind( Resolvable::Kind::patch );
- q2.addKind( Resolvable::Kind::patch );
- q2.addKind( Resolvable::Kind::pattern );
-
- savedQueries.push_front( q1 );
- savedQueries.push_front( q2 );
-
- writePoolQueriesToFile ( tmpPath, savedQueries.begin(), savedQueries.end() );
- std::insert_iterator<std::list<PoolQuery> > ii2(savedQueries,
- savedQueries.end());
- //reread writed queries
- readPoolQueriesFromFile( tmpPath, ii2);
- //TODO test if 0==2 and 1==3
- BOOST_CHECK( savedQueries.size() == 4 );
-
-}
private:
friend class IdStringType<PoolQueryAttr>;
IdString _str;
+ sat::SolvAttr sa;
public:
: _str( str_r ),isSolvAttr(false)
{
if( _str==noAttr ){
- sat::SolvAttr sa(str_r);
+ string s(str_r);
+ boost::replace_all(s,"_",":");
+ sa = sat::SolvAttr(s);
if( sa != sat::SolvAttr::noAttr )
{
isSolvAttr = true;
}
}
+ const sat::SolvAttr& solvAttr() { return sa;}
+
//unknown atributes
static const PoolQueryAttr noAttr;
finded_something = true;
- string atrName(str::trim(string(s,0,pos))); // trimmed name of atribute
- string atrValue(str::trim(string(s,pos+1,s.npos))); //trimmed value
+ string attrName(str::trim(string(s,0,pos))); // trimmed name of atribute
+ string attrValue(str::trim(string(s,pos+1,s.npos))); //trimmed value
- PoolQueryAttr attribute( atrName );
+ PoolQueryAttr attribute( attrName );
if ( attribute==PoolQueryAttr::repoAttr )
{
- addRepo( atrValue );
+ addRepo( attrValue );
}
else if ( attribute==PoolQueryAttr::kindAttr )
{
- addKind( Resolvable::Kind(atrValue) );
+ addKind( Resolvable::Kind(attrValue) );
}
else if ( attribute==PoolQueryAttr::noAttr )
{
if (attribute.isSolvAttr)
{
- //setAtribute
+ addAttribute(attribute.solvAttr(),attrValue);
}
else
{
- //log unknwon atribute
+ WAR << "unknown attribute " << attrName << endl;
}
}
else
{
- //some forget handle new atribute
- ;
+ WAR << "forget recover some attribute defined as PoolQuery attribute: " << attrName << endl;
}
} while ( true );