File: RepoFileReader_test.cc

package info (click to toggle)
libzypp 17.38.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 27,744 kB
  • sloc: cpp: 132,661; xml: 2,587; sh: 518; python: 266; makefile: 27
file content (58 lines) | stat: -rw-r--r-- 1,697 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <sstream>
#include <string>
#include <zypp/parser/RepoFileReader.h>
#include <zypp-core/base/NonCopyable.h>

#include <tests/lib/TestSetup.h>

using std::stringstream;
using std::string;
using namespace zypp;

static std::string suse_repo = "[factory-oss]\n"
"name=factory-oss $releasever - $basearch\n"
"failovermethod=priority\n"
"enabled=1\n"
"gpgcheck=1\n"
"autorefresh=0\n"
"baseurl=http://serv.er/loc1\n"
"baseurl=http://serv.er/loc2\n"
"        http://serv.er/loc3  ,   http://serv.er/loc4     http://serv.er/loc5\n"
"gpgkey=http://serv.er/loc1\n"
"gpgkey=http://serv.er/loc2\n"
"        http://serv.er/loc3  ,   http://serv.er/loc4     http://serv.er/loc5\n"
"mirrorlist=http://serv.er/loc1\n"
"mirrorlist=http://serv.er/loc2\n"
"        http://serv.er/loc3  ,   http://serv.er/loc4     http://serv.er/loc5\n"
"type=NONE\n"
"keeppackages=0\n";

struct RepoCollector : private base::NonCopyable
{
  bool collect( const RepoInfo &repo )
  {
    repos.push_back(repo);
    return true;
  }

  RepoInfoList repos;
};

// Must be the first test!
BOOST_AUTO_TEST_CASE(read_repo_file)
{
  {
    std::stringstream input(suse_repo);
    RepoCollector collector;
    parser::RepoFileReader parser( input, bind( &RepoCollector::collect, &collector, _1 ) );
    BOOST_CHECK_EQUAL(1, collector.repos.size());

    const RepoInfo & repo( collector.repos.front() );

    BOOST_CHECK_EQUAL( 5, repo.baseUrlsSize() );
    BOOST_CHECK_EQUAL( 5, repo.gpgKeyUrlsSize() );
    BOOST_CHECK_EQUAL( Url("http://serv.er/loc1"), *repo.baseUrlsBegin() );
    BOOST_CHECK_EQUAL( Url("http://serv.er/loc1"), repo.gpgKeyUrl() );
    BOOST_CHECK_EQUAL( Url("http://serv.er/loc1"), repo.mirrorListUrl() );
  }
}