- rework the testsuite after new boost in factory broke it.
[platform/upstream/libzypp.git] / tests / repo / RepoVariables_test.cc
1 #include <stdio.h>
2 #include <iostream>
3 #include <fstream>
4 #include <vector>
5 #include <list>
6 #include <boost/test/unit_test.hpp>
7
8 #include "zypp/ZYppFactory.h"
9 #include "zypp/Url.h"
10 #include "zypp/PathInfo.h"
11 #include "zypp/TmpPath.h"
12 #include "zypp/ZConfig.h"
13 #include "zypp/repo/RepoVariables.h"
14
15 using std::cout;
16 using std::endl;
17 using std::string;
18 using namespace zypp;
19 using namespace boost::unit_test;
20 using namespace zypp::repo;
21
22 #define DATADIR (Pathname(TESTS_SRC_DIR) +  "/repo/yum/data")
23
24 BOOST_AUTO_TEST_CASE(replace_text)
25 {
26   /* check RepoVariablesStringReplacer */
27
28   RepoVariablesStringReplacer replacer1;
29
30   BOOST_CHECK_EQUAL(replacer1("http://foo/$arch/bar"),
31                     "http://foo/"+ ZConfig::instance().systemArchitecture().asString() + "/bar");
32
33   getZYpp()->setArchitecture(Arch("i686"));
34   BOOST_CHECK_EQUAL(replacer1("http://foo/$arch/bar/$basearch"),
35                     "http://foo/i686/bar/i386");
36
37   /* check RepoVariablesUrlReplacer */
38
39   RepoVariablesUrlReplacer replacer2;
40
41   BOOST_CHECK_EQUAL(replacer2(Url("ftp://user:secret@site.org/$arch/")).asCompleteString(),
42                     "ftp://user:secret@site.org/i686/");
43
44   BOOST_CHECK_EQUAL(replacer2(Url("http://user:my$arch@site.org/$basearch/")).asCompleteString(),
45                     "http://user:my$arch@site.org/i386/");
46
47   BOOST_CHECK_EQUAL(replacer2(Url("http://site.org/update/?arch=$arch")).asCompleteString(),
48                     "http://site.org/update/?arch=i686");
49 }
50
51 // vim: set ts=2 sts=2 sw=2 ai et: