#include <fstream>
#include <vector>
#include <list>
-#include <boost/test/unit_test.hpp>
-#include <boost/test/parameterized_test.hpp>
-#include <boost/test/unit_test_log.hpp>
+#include <boost/test/auto_unit_test.hpp>
+#include <solv/solvversion.h>
#include "zypp/base/Logger.h"
#include "zypp/Url.h"
#include "zypp/PathInfo.h"
#include "zypp/TmpPath.h"
#include "zypp/repo/yum/Downloader.h"
+#include "tests/zypp/KeyRingTestReceiver.h"
using std::cout;
using std::endl;
-using std::string;
using namespace zypp;
using namespace boost::unit_test;
-using namespace zypp::repo;
-
-#include "tests/zypp/KeyRingTestReceiver.h"
+#define DATADIR (Pathname(TESTS_SRC_DIR) + "/repo/yum/data")
-void yum_download_test(const string &dir)
+BOOST_AUTO_TEST_CASE(yum_download)
{
KeyRingTestReceiver keyring_callbacks;
- keyring_callbacks.answerTrustKey(true);
+ keyring_callbacks.answerAcceptKey(KeyRingReport::KEY_TRUST_TEMPORARILY);
- Pathname p = dir + "/10.2-updates-subset";
- Url url("dir:" + p.asString());
+ Pathname p = DATADIR + "/ZCHUNK";
+ Url url(p.asDirUrl());
MediaSetAccess media(url);
- yum::Downloader yum("/");
+ RepoInfo repoinfo;
+ repoinfo.setAlias("testrepo");
+ repoinfo.setPath("/");
+ repo::yum::Downloader yum(repoinfo);
filesystem::TmpDir tmp;
-
+
Pathname localdir(tmp.path());
-
+
yum.download(media, localdir);
-
- const char* files[] =
- {
-// "filelists.xml.gz",
-// "other.xml.gz",
- "patches.xml",
- "patch-fetchmsttfonts.sh-2333.xml",
- "patch-flash-player-2359.xml",
- "patch-glabels-2348.xml",
- "patch-gv-2350.xml",
- "patch-openssl-2349.xml",
- "patch-tar-2351.xml",
- "primary.xml.gz",
- "repomd.xml",
- "repomd.xml.asc",
- "repomd.xml.key",
- NULL
- };
-
- int i=0;
- while ( files[i] != NULL )
- {
- BOOST_CHECK_MESSAGE( PathInfo(localdir + "/repodata/" + files[i] ).isExist(), (string("/repodata/") + files[i]).c_str() );
- i++;
- }
-}
+#ifdef LIBSOLVEXT_FEATURE_ZSTD_COMPRESSION
+ const bool zchunk = true;
+#else
+ const bool zchunk = false;
+#endif
+ std::map<std::string,bool> files {
+ { "filelists.xml.gz", false&&!zchunk },
+ { "filelists.xml.zck", false&&zchunk },
+ { "other.xml.gz", false&&!zchunk },
+ { "other.xml.zck", false&&zchunk },
+ { "patterns.xml.gz", true },
+ { "primary.xml.gz", !zchunk },
+ { "primary.xml.zck", zchunk },
+ { "repomd.xml", true },
+ { "repomd.xml.asc", true },
+ { "repomd.xml.key", true },
+ };
-test_suite*
-init_unit_test_suite( int argc, char *argv[] )
-{
- string datadir;
- if (argc < 2)
+ for ( const auto & el : files )
{
- datadir = TESTS_SRC_DIR;
- datadir = (Pathname(datadir) + "/repo/yum/data").asString();
- cout << "YUMDownloader_test:"
- " path to directory with test data required as parameter. Using " << datadir << endl;
- //return (test_suite *)0;
-
+ Pathname stem { "/repodata/"+el.first };
+ bool downloaded { PathInfo(localdir/stem).isExist() };
+ BOOST_CHECK_MESSAGE( downloaded == el.second, std::string(el.second?"missing ":"unexpected ")+stem );
}
- else
- {
- datadir = argv[1];
- }
-
- test_suite* test= BOOST_TEST_SUITE("YUMDownloader");
-
- std::string const params[] = { datadir };
- test->add(BOOST_PARAM_TEST_CASE(&yum_download_test,
- (std::string const*)params, params+1));
- return test;
+
}
// vim: set ts=2 sts=2 sw=2 ai et: