1 #include <gtest/gtest.h>
3 #include <boost/filesystem.hpp>
6 #include "config/config.h"
7 #include "package_manager/packagemanagerfactory.h"
8 #include "package_manager/packagemanagerinterface.h"
9 #include "storage/invstorage.h"
10 #include "utilities/utils.h"
12 boost::filesystem::path sysroot;
17 config.pacman.type = PACKAGE_MANAGER_OSTREE;
18 config.pacman.sysroot = sysroot;
20 config.storage.path = dir.Path();
21 std::shared_ptr<INvStorage> storage = INvStorage::newStorage(config.storage);
22 std::shared_ptr<PackageManagerInterface> pacman =
23 PackageManagerFactory::makePackageManager(config.pacman, config.bootloader, storage,
nullptr);
31 config.pacman.type = PACKAGE_MANAGER_DEBIAN;
33 config.storage.path = dir.Path();
34 std::shared_ptr<INvStorage> storage = INvStorage::newStorage(config.storage);
35 std::shared_ptr<PackageManagerInterface> pacman =
36 PackageManagerFactory::makePackageManager(config.pacman, config.bootloader, storage,
nullptr);
44 config.storage.path = dir.Path();
45 std::shared_ptr<INvStorage> storage = INvStorage::newStorage(config.storage);
46 config.pacman.type = PACKAGE_MANAGER_NONE;
47 std::shared_ptr<PackageManagerInterface> pacman =
48 PackageManagerFactory::makePackageManager(config.pacman, config.bootloader, storage,
nullptr);
55 config.storage.path = dir.Path();
56 config.pacman.type =
"bad";
57 std::shared_ptr<INvStorage> storage = INvStorage::newStorage(config.storage);
58 EXPECT_THROW(PackageManagerFactory::makePackageManager(config.pacman, config.bootloader, storage,
nullptr),
62 #include "package_manager/packagemanagerfake.h"
66 EXPECT_THROW(PackageManagerFactory::registerPackageManager(
70 throw std::runtime_error(
"unimplemented");
74 PackageManagerFactory::registerPackageManager(
83 config.storage.path = temp_dir.Path();
84 config.pacman.type =
"new";
85 std::shared_ptr<INvStorage> storage = INvStorage::newStorage(config.storage);
87 EXPECT_NE(PackageManagerFactory::makePackageManager(config.pacman, config.bootloader, storage,
nullptr),
nullptr);
91 int main(
int argc,
char** argv) {
92 ::testing::InitGoogleTest(&argc, argv);
95 std::cerr <<
"Error: " << argv[0] <<
" requires the path to an OSTree sysroot as an input argument.\n";
99 return RUN_ALL_TESTS();