gdpm/tests/basic.cpp
David J. Allen 5a73651ad1 Major refactor and API changes
- Updated `.gitignore` file
- Updated `CMakeLists.txt` to build static exectuable
- Changed some `Doxyfile` configurations to build more robust and complete documentation (WIP)
- Changed how `remote` works to better reflect `git`'s API (WIP)
- Changed how error handling works
- Improved `bin/compile.sh` script
- Improved `bin/lines.sh` script (kinda)
- Removed some instances of `fmt` in favor of `std` string functions
- Restructed style for better readibility
2023-05-22 17:54:45 -06:00

70 lines
No EOL
1.5 KiB
C++

#include "package_manager.hpp"
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "log.hpp"
#include "cache.hpp"
#include "config.hpp"
#include "package.hpp"
#include <doctest.h>
TEST_SUITE("Caching functions"){
TEST_CASE("Test cache database functions"){
gdpm::cache::create_package_database();
}
}
TEST_SUITE("Command functions"){
using namespace gdpm;
using namespace gdpm::package_manager;
config::context config = config::make_context();
package::params params = package::params();
package::title_list package_titles{"ResolutionManagerPlugin","godot-hmac", "Godot"};
auto check_error = [](const error& error){
if(error.has_occurred()){
log::error(error);
}
CHECK(!error.has_occurred());
};
TEST_CASE("Test install packages"){
check_error(package::install(config, package_titles, params));
}
TEST_CASE("Test searching packages"){
check_error(package::search(config, package_titles, params));
}
TEST_CASE("Test remove packages"){
check_error(package::remove(config, package_titles, params));
}
TEST_CASE("Test exporting installed package list"){
check_error(package::export_to({"tests/gdpm/.tmp/packages.txt"}));
}
}
TEST_CASE("Test configuration functions"){
using namespace gdpm;
config::context config = config::make_context();
config.path = constants::TestPath + "/";
std::string json = config::to_json(config);
error error_save = config::save(config.path, config);
CHECK(error_save.get_code() == 0);
error error_load = config::load(config.path, config);
CHECK(error_load.get_code() == 0);
}