- provided context to keyring callbacks (bnc #370223)
[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/auto_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.answerAcceptKey(KeyRingReport::KEY_TRUST_TEMPORARILY);
29
30   Pathname p = DATADIR + "/10.2-updates-subset";
31   Url url("dir:" + p.asString());
32   MediaSetAccess media(url);
33   RepoInfo repoinfo;
34   repoinfo.setAlias("testrepo");
35   repoinfo.setPath("/");
36   yum::Downloader yum(repoinfo);
37   filesystem::TmpDir tmp;
38
39   Pathname localdir(tmp.path());
40   
41   yum.download(media, localdir);
42   
43   const char* files[] =
44   {
45 //    "filelists.xml.gz",
46 //    "other.xml.gz",
47     "patches.xml",
48     "patch-fetchmsttfonts.sh-2333.xml",
49     "patch-flash-player-2359.xml",
50     "patch-glabels-2348.xml",
51     "patch-gv-2350.xml",
52     "patch-openssl-2349.xml",
53     "patch-tar-2351.xml",
54     "primary.xml.gz",
55     "repomd.xml",
56     "repomd.xml.asc",
57     "repomd.xml.key",
58     NULL
59   };
60   
61   int i=0;
62   while ( files[i] != NULL )
63   {
64     BOOST_CHECK_MESSAGE( PathInfo(localdir + "/repodata/" + files[i] ).isExist(), (string("/repodata/") + files[i]).c_str() );
65     i++;
66   }
67
68 }
69
70 // vim: set ts=2 sts=2 sw=2 ai et: