File: RepoindexFileReader_test.cc

package info (click to toggle)
libzypp 17.38.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 27,716 kB
  • sloc: cpp: 132,661; xml: 2,587; sh: 518; python: 266; makefile: 27
file content (69 lines) | stat: -rw-r--r-- 2,240 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
59
60
61
62
63
64
65
66
67
68
69
#include <sstream>
#include <string>
#include <zypp-core/Pathname.h>
#include <zypp/parser/RepoindexFileReader.h>
#include <zypp-core/base/NonCopyable.h>

#include <tests/lib/TestSetup.h>

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

static string service = "<repoindex arch=\"i386\" distver=\"11\">"
  "<repo alias=\"company-foo\" name=\"Company's Foo\""
  "      path=\"products/foo\" distro_target=\"sle-%{distver}-%{arch}\" priority=\"20\"/>"
  "<repo alias=\"company-bar\" name=\"Company's Bar\""
  "      path=\"products/bar\" distro_target=\"sle-%{distver}-%{arch}\" enabled=\"tRUe\" autorefresh=\"FaLsE\"/>"
  "<repo alias=\"company-foo-upd\" name=\"Company's Foo Updates\""
  "      path=\"products/foo/updates\" distro_target=\"sle-%{distver}-%{arch}\" priority=\"1\"/>"
  "</repoindex>";

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_index_file)
{
  {
    stringstream input(service);
    RepoCollector collector;
    parser::RepoindexFileReader parser( input, bind( &RepoCollector::collect, &collector, _1 ) );
    BOOST_REQUIRE_EQUAL(3, collector.repos.size());

    RepoInfo repo;
    repo = collector.repos.front();

    BOOST_CHECK_EQUAL("Company's Foo", repo.name());
    BOOST_CHECK_EQUAL("company-foo", repo.alias());
    BOOST_CHECK_EQUAL("sle-11-i386", repo.targetDistribution());
    BOOST_CHECK_EQUAL(20, repo.priority());
    // "Repository is per default disabled"
    BOOST_CHECK(!repo.enabled());
    // "Repository autorefresh is per default enabled"
    BOOST_CHECK(repo.autorefresh());
    BOOST_CHECK_EQUAL("/repo/products/foo", repo.path());

    collector.repos.pop_front( );
    repo = collector.repos.front();

    BOOST_CHECK_EQUAL("company-bar", repo.alias());
    BOOST_CHECK_EQUAL("sle-11-i386", repo.targetDistribution());
    // "Priority should be 99 when not explictly defined"
    BOOST_CHECK_EQUAL(99, repo.priority());
    // "Repository is explicitly enabled"
    BOOST_CHECK(repo.enabled());
    // "Repository autorefresh is explicitly disabled"
    BOOST_CHECK(!repo.autorefresh());


  }
}