993d2302ba4bb9a1ee770a2626cb02818c23e5c9
[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
8 #include "zypp/base/Logger.h"
9 #include "zypp/Url.h"
10 #include "zypp/PathInfo.h"
11 #include "zypp/TmpPath.h"
12 #include "zypp/repo/yum/Downloader.h"
13
14 using std::cout;
15 using std::endl;
16 using std::string;
17 using namespace zypp;
18 using namespace boost::unit_test;
19 using namespace zypp::repo;
20
21 #include "tests/zypp/KeyRingTestReceiver.h"
22
23 #define DATADIR (Pathname(TESTS_SRC_DIR) + "/repo/yum/data")
24
25 BOOST_AUTO_TEST_CASE(yum_download)
26 {
27   KeyRingTestReceiver keyring_callbacks;
28   keyring_callbacks.answerTrustKey(true);
29
30   Pathname p = DATADIR + "/10.2-updates-subset";
31   Url url("dir:" + p.asString());
32   MediaSetAccess media(url);
33   yum::Downloader yum("/");
34   filesystem::TmpDir tmp;
35   
36   Pathname localdir(tmp.path());
37   
38   yum.download(media, localdir);
39   
40   const char* files[] =
41   {
42 //    "filelists.xml.gz",
43 //    "other.xml.gz",
44     "patches.xml",
45     "patch-fetchmsttfonts.sh-2333.xml",
46     "patch-flash-player-2359.xml",
47     "patch-glabels-2348.xml",
48     "patch-gv-2350.xml",
49     "patch-openssl-2349.xml",
50     "patch-tar-2351.xml",
51     "primary.xml.gz",
52     "repomd.xml",
53     "repomd.xml.asc",
54     "repomd.xml.key",
55     NULL
56   };
57   
58   int i=0;
59   while ( files[i] != NULL )
60   {
61     BOOST_CHECK_MESSAGE( PathInfo(localdir + "/repodata/" + files[i] ).isExist(), (string("/repodata/") + files[i]).c_str() );
62     i++;
63   }
64
65 }
66
67 // vim: set ts=2 sts=2 sw=2 ai et: