3 #include <zypp/parser/RepoFileReader.h>
4 #include <zypp/base/NonCopyable.h>
8 using std::stringstream;
12 static string suse_repo = "[factory-oss]\n"
16 "baseurl=http://download.opensuse.org/factory-tested/repo/oss/\n"
20 static string fedora_repo = "[fedora]\n"
21 "name=Fedora $releasever - $basearch\n"
22 "failovermethod=priority\n"
23 "#baseurl=http://download.fedora.redhat.com/pub/fedora/linux/releases/$releasever/Everything/$basearch/os/\n"
24 "#mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-$releasever&arch=$basearch\n"
25 "mirrorlist=file:///etc/yum.repos.d/local.mirror\n"
28 "gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora file:///etc/pki/rpm-gpg/RPM-GPG-KEY\n";
30 struct RepoCollector : private base::NonCopyable
32 bool collect( const RepoInfo &repo )
34 repos.push_back(repo);
41 // Must be the first test!
42 BOOST_AUTO_TEST_CASE(read_repo_file)
45 stringstream input(suse_repo);
46 RepoCollector collector;
47 parser::RepoFileReader parser( input, bind( &RepoCollector::collect, &collector, _1 ) );
48 BOOST_CHECK_EQUAL(1, collector.repos.size());
52 stringstream input(fedora_repo);
53 RepoCollector collector;
54 parser::RepoFileReader parser( input, bind( &RepoCollector::collect, &collector, _1 ) );
55 BOOST_REQUIRE_EQUAL(1, collector.repos.size());
57 RepoInfo repo = *collector.repos.begin();
58 // should have taken the first url if more are present
59 BOOST_CHECK_EQUAL(Url("file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora"), repo.gpgKeyUrl());