File: Pool_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 (100 lines) | stat: -rw-r--r-- 2,671 bytes parent folder | download | duplicates (2)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include <tests/lib/TestSetup.h>
#include <zypp/Repository.h>
#include <zypp/sat/Pool.h>

static TestSetup test( TestSetup::initLater );
struct TestInit {
  TestInit() {
    test = TestSetup( Arch_x86_64 );
  }
  ~TestInit() { test.reset(); }
};
BOOST_GLOBAL_FIXTURE( TestInit );

namespace zypp { namespace detail {
  /** \relates RepositoryIterator Stream output */
  inline std::ostream & operator<<( std::ostream & str, const RepositoryIterator & obj )
  {
    str << "RI["<< *obj <<"]";
    return str;
  }
}}

// Must be the first test!
BOOST_AUTO_TEST_CASE(findSystemRepo)
{
  // On the fly check that findSystemRepo does not
  // cause loading the SystemRepo. check 2 times.
  BOOST_REQUIRE( ! test.satpool().findSystemRepo() );
  BOOST_REQUIRE( ! test.satpool().findSystemRepo() );
}

void checkRepoIter()
{
  sat::Pool satpool( test.satpool() );
  sat::Pool::size_type count = satpool.reposSize();
  for_( it, satpool.reposBegin(), satpool.reposEnd() )
  {
    cout << "- " << count << " " << *it << endl;
    BOOST_CHECK( *it );
    --count;
  }
  BOOST_CHECK_EQUAL( count, 0 );
}


BOOST_AUTO_TEST_CASE(repolist)
{
  // libzypp-11: underlying libsolv changed the pools repository
  // pointer list. It may now contain emebeded NULLs which have
  // to be skipped when iterating the repos.
  //
  sat::Pool satpool( test.satpool() );
  BOOST_CHECK( satpool.reposEmpty() );
  BOOST_CHECK_EQUAL( satpool.reposSize(), 0 );
  checkRepoIter();

  // empty @system to pool
  test.satpool().systemRepo();
  BOOST_REQUIRE( satpool.findSystemRepo() );
  BOOST_CHECK( !satpool.reposEmpty() );
  BOOST_CHECK_EQUAL( satpool.reposSize(), 1 );
  checkRepoIter();

  test.loadRepo( TESTS_SRC_DIR "/data/obs_virtualbox_11_1" );
  BOOST_CHECK( !satpool.reposEmpty() );
  BOOST_CHECK_EQUAL( satpool.reposSize(), 2 );
  checkRepoIter();

  test.loadRepo( TESTS_SRC_DIR "/data/11.0-update" );
  BOOST_CHECK( !satpool.reposEmpty() );
  BOOST_CHECK_EQUAL( satpool.reposSize(), 3 );
  checkRepoIter();

  satpool.reposErase( ":obs_virtualbox_11_1" );
  BOOST_CHECK( !satpool.reposEmpty() );
  BOOST_CHECK_EQUAL( satpool.reposSize(), 2 );
  checkRepoIter();

  satpool.reposErase( ":11.0-update" );
  test.loadRepo( TESTS_SRC_DIR "/data/openSUSE-11.1" );
  BOOST_CHECK( !satpool.reposEmpty() );
  BOOST_CHECK_EQUAL( satpool.reposSize(), 2 );
  checkRepoIter();



/*  for_( it, satpool.reposBegin(),  satpool.reposEnd() )
  {
    cout << "- " << *it << endl;
  }*/
  //test.loadRepo( TESTS_SRC_DIR "/data/openSUSE-11.1" );
}

#if 0
BOOST_AUTO_TEST_CASE(LookupAttr_)
{
  base::LogControl::TmpLineWriter shutUp( new log::FileLineWriter( "/tmp/YLOG" ) );
  MIL << "GO" << endl;
}
#endif