6 #include <boost/test/auto_unit_test.hpp>
8 #include "zypp/parser/yum/RepomdFileReader.h"
10 #include "zypp/PathInfo.h"
14 using namespace boost::unit_test;
16 using namespace zypp::parser::yum;
17 using repo::yum::ResourceType;
19 #define DATADIR (Pathname(TESTS_SRC_DIR) + "parser/yum/data")
27 bool callback( const OnMediaLocation &loc, const ResourceType &t )
29 items.push_back( make_pair( t, loc ) );
30 //items.push_back(loc);
31 //cout << items.size() << endl;
35 vector<pair<ResourceType, OnMediaLocation> > items;
36 //vector<OnMediaLocation> items;
39 BOOST_AUTO_TEST_CASE(repomd_read)
41 list<Pathname> entries;
42 if ( filesystem::readdir( entries, DATADIR, false ) != 0 )
43 ZYPP_THROW(Exception("failed to read directory"));
45 for ( list<Pathname>::const_iterator it = entries.begin(); it != entries.end(); ++it )
48 if ( ( file.basename().substr(0, 6) == "repomd" ) && (file.extension() == ".xml" ) )
53 RepomdFileReader( file, RepomdFileReader::ProcessResource(bind( &Collector::callback, &collect, _1, _2 )) );
55 std::ifstream ifs( file.extend(".solution").asString().c_str() );
57 unsigned int count = 0;
58 while ( ifs && ! ifs.eof() && count < collect.items.size() )
66 BOOST_CHECK_EQUAL( collect.items[count].first, ResourceType(dtype));
67 getline(ifs, checksum_type);
68 getline(ifs, checksum);
69 BOOST_CHECK_EQUAL( collect.items[count].second.checksum(), CheckSum(checksum_type, checksum) );
71 BOOST_CHECK_EQUAL( collect.items[count].second.filename(), Pathname(loc) );
75 BOOST_CHECK_EQUAL( collect.items.size(), count );
81 // vim: set ts=2 sts=2 sw=2 ai et: