7 #include <boost/test/unit_test.hpp>
9 #include "zypp/base/Logger.h"
10 #include "zypp/base/Exception.h"
11 #include "zypp/PathInfo.h"
12 #include "zypp/TmpPath.h"
13 #include "zypp/Package.h"
14 #include "zypp/RepoManager.h"
15 #include "zypp/sat/Pool.h"
16 #include "KeyRingTestReceiver.h"
18 #include "TestSetup.h"
20 using boost::unit_test::test_case;
24 using namespace zypp::repo;
25 using namespace zypp::filesystem;
27 #define TEST_DIR TESTS_SRC_DIR "/repo/yum/data/extensions"
29 BOOST_AUTO_TEST_CASE(extended_metadata)
31 KeyRingTestReceiver rec;
32 //rec.answerAcceptUnknownKey(true);
33 rec.answerAcceptUnsignedFile(true);
36 // rec.answerImportKey(true);
37 Pathname repodir(TEST_DIR );
39 sat::Pool pool(sat::Pool::instance());
41 TestSetup test( Arch_x86_64 );
42 test.loadRepo(repodir.absolutename().asDirUrl(), "updates");
44 Repository repo = pool.reposFind("updates");
46 BOOST_CHECK_EQUAL( repo.generatedTimestamp(), Date(1227279057) );
47 BOOST_CHECK_EQUAL( repo.suggestedExpirationTimestamp(), Date(1227279057 + 3600) );
49 // check that the attributes of product compatibility are ok
52 vector<string> labels;
55 repo.compatibleWithProductBegin(),
56 repo.compatibleWithProductEnd() )
58 cpeids.push_back(it.cpeId());
59 labels.push_back(it.label());
63 // there were 2 compatible products
64 BOOST_CHECK_EQUAL( count, 2 );
65 BOOST_CHECK_EQUAL( cpeids[0], "cpe:/o:opensuse" );
66 BOOST_CHECK_EQUAL( cpeids[1], "cpe:/o:sle" );
68 BOOST_CHECK_EQUAL( labels[0], "openSUSE 11.0" );
69 BOOST_CHECK_EQUAL( labels[1], "SLE 11.0" );
76 repo.updatesProductBegin(),
77 repo.updatesProductEnd() )
79 cpeids.push_back(it.cpeId());
80 labels.push_back(it.label());
84 // the repo updates one product
85 BOOST_CHECK_EQUAL( count, 1 );
86 BOOST_CHECK_EQUAL( cpeids[0], "cpe:/o:sle" );
87 BOOST_CHECK_EQUAL( labels[0], "SLE 11.0" );
89 // because this product updates something, it _is_ an update repo
90 BOOST_CHECK( repo.isUpdateRepo() );
92 BOOST_CHECK( repo.providesUpdatesFor(CpeId("cpe:/o:sle")) );
93 BOOST_CHECK( ! repo.providesUpdatesFor(CpeId("cpe:/o:windows")) );
94 // reuse to count solvables
98 * Now check for the extended metadata of the packages
100 for_( it, repo.solvablesBegin(), repo.solvablesEnd() )
102 sat::Solvable s = *it;
104 MIL << s.kind() << endl;
105 if ( s.ident() == "wt" )
108 Package::Ptr p = asKind<Package>(makeResObject(s));
110 BOOST_CHECK(p->maybeUnsupported() );
111 BOOST_CHECK_EQUAL(p->vendorSupport(), VendorSupportUnknown );
114 else if ( s.ident() == "foobar" )
117 Package::Ptr p = asKind<Package>(makeResObject(s));
119 BOOST_CHECK_EQUAL(p->vendorSupport(), VendorSupportUnsupported );
120 BOOST_CHECK(p->maybeUnsupported() );
122 else if ( s.ident() == "foofoo" )
125 Package::Ptr p = asKind<Package>(makeResObject(s));
127 // if it is level 3 support it cant be unsupported
128 BOOST_CHECK_EQUAL(p->vendorSupport(), VendorSupportLevel3 );
129 BOOST_CHECK(! p->maybeUnsupported() );
134 BOOST_FAIL(str::form("Repo has package not contemplated in test: %s", s.ident().c_str()).c_str());
139 // check that we actually found all testeable
141 BOOST_CHECK_EQUAL(count, 3);