- Fixes for the checksum/signature subsystem (#302059)
[platform/upstream/libzypp.git] / tests / repo / yum / YUMDownloader_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 #include <boost/test/parameterized_test.hpp>
8 #include <boost/test/unit_test_log.hpp>
9
10 #include "zypp/base/Logger.h"
11 #include "zypp/Url.h"
12 #include "zypp/PathInfo.h"
13 #include "zypp/TmpPath.h"
14 #include "zypp/repo/yum/Downloader.h"
15
16 using std::cout;
17 using std::endl;
18 using std::string;
19 using namespace zypp;
20 using namespace boost::unit_test;
21
22 using namespace zypp::repo;
23
24 #include "tests/zypp/KeyRingTestReceiver.h"
25
26 void yum_download_test(const string &dir)
27 {
28   KeyRingTestReceiver keyring_callbacks;
29   keyring_callbacks.answerTrustKey(true);
30
31   Pathname p = dir + "/10.2-updates-subset";
32   Url url("dir:" + p.asString());
33   MediaSetAccess media(url);
34   yum::Downloader yum("/");
35   filesystem::TmpDir tmp;
36   
37   Pathname localdir(tmp.path());
38   
39   yum.download(media, localdir);
40   
41   const char* files[] =
42   {
43     "filelists.xml.gz",
44 //    "other.xml.gz",
45     "patches.xml",
46     "patch-fetchmsttfonts.sh-2333.xml",
47     "patch-flash-player-2359.xml",
48     "patch-glabels-2348.xml",
49     "patch-gv-2350.xml",
50     "patch-openssl-2349.xml",
51     "patch-tar-2351.xml",
52     "primary.xml.gz",
53     "repomd.xml",
54     "repomd.xml.asc",
55     "repomd.xml.key",
56     NULL
57   };
58   
59   int i=0;
60   while ( files[i] != NULL )
61   {
62     BOOST_CHECK_MESSAGE( PathInfo(localdir + "/repodata/" + files[i] ).isExist(), (string("/repodata/") + files[i]).c_str() );
63     i++;
64   }
65
66 }
67
68 test_suite*
69 init_unit_test_suite( int argc, char *argv[] )
70 {
71   string datadir;
72   if (argc < 2)
73   {
74     datadir = TESTS_SRC_DIR;
75     datadir = (Pathname(datadir) + "/repo/yum/data").asString();
76     cout << "YUMDownloader_test:"
77       " path to directory with test data required as parameter. Using " << datadir  << endl;
78     //return (test_suite *)0;
79     
80   }
81   else
82   {
83     datadir = argv[1];
84   }
85   
86   test_suite* test= BOOST_TEST_SUITE("YUMDownloader");
87   
88   std::string const params[] = { datadir };
89   test->add(BOOST_PARAM_TEST_CASE(&yum_download_test,
90                                  (std::string const*)params, params+1));
91   return test;
92 }
93
94 // vim: set ts=2 sts=2 sw=2 ai et: