[M5+] drop curated linkdb JSON; SQLite overlay is the single source
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
import cargoxx.cli;
|
||||
import cargoxx.linkdb;
|
||||
import cargoxx.manifest;
|
||||
import cargoxx.util;
|
||||
import std;
|
||||
|
||||
using cargoxx::cli::cmd_add;
|
||||
using cargoxx::cli::cmd_new;
|
||||
using cargoxx::linkdb::Database;
|
||||
using cargoxx::linkdb::Recipe;
|
||||
using cargoxx::util::ErrorCode;
|
||||
namespace manifest = cargoxx::manifest;
|
||||
|
||||
@@ -36,11 +39,25 @@ auto scaffold(const std::filesystem::path& parent) -> std::filesystem::path {
|
||||
return parent / "app";
|
||||
}
|
||||
|
||||
auto seed_fmt(const std::filesystem::path& overlay) {
|
||||
auto db = Database::open(overlay);
|
||||
REQUIRE(db.has_value());
|
||||
REQUIRE(db->add_manual("fmt", "*",
|
||||
Recipe{
|
||||
.nixpkgs_attr = "fmt_10",
|
||||
.find_package = "fmt CONFIG REQUIRED",
|
||||
.targets = {"fmt::fmt"},
|
||||
.source = "manual",
|
||||
})
|
||||
.has_value());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST_CASE("cmd_add appends a string-form dependency", "[cli][add]") {
|
||||
auto parent = fresh_dir();
|
||||
auto root = scaffold(parent);
|
||||
seed_fmt(overlay_path(parent));
|
||||
|
||||
auto r = cmd_add(root, "fmt", "10.2.0", {}, overlay_path(parent));
|
||||
REQUIRE(r.has_value());
|
||||
@@ -53,25 +70,10 @@ TEST_CASE("cmd_add appends a string-form dependency", "[cli][add]") {
|
||||
REQUIRE(m->dependencies[0].components.empty());
|
||||
}
|
||||
|
||||
TEST_CASE("cmd_add stores components when provided", "[cli][add]") {
|
||||
auto parent = fresh_dir();
|
||||
auto root = scaffold(parent);
|
||||
|
||||
auto r = cmd_add(root, "abseil-cpp", "20240116.0", {"strings", "base"},
|
||||
overlay_path(parent));
|
||||
REQUIRE(r.has_value());
|
||||
|
||||
auto m = manifest::parse(root / "Cargoxx.toml");
|
||||
REQUIRE(m.has_value());
|
||||
REQUIRE(m->dependencies.size() == 1);
|
||||
REQUIRE(m->dependencies[0].name == "abseil-cpp");
|
||||
REQUIRE(m->dependencies[0].components ==
|
||||
std::vector<std::string>{"strings", "base"});
|
||||
}
|
||||
|
||||
TEST_CASE("cmd_add accepts an empty version and stores '*'", "[cli][add]") {
|
||||
auto parent = fresh_dir();
|
||||
auto root = scaffold(parent);
|
||||
seed_fmt(overlay_path(parent));
|
||||
|
||||
auto r = cmd_add(root, "fmt", "", {}, overlay_path(parent));
|
||||
REQUIRE(r.has_value());
|
||||
@@ -105,6 +107,7 @@ TEST_CASE("cmd_add rejects an unknown package", "[cli][add]") {
|
||||
TEST_CASE("cmd_add rejects an already-declared dep", "[cli][add]") {
|
||||
auto parent = fresh_dir();
|
||||
auto root = scaffold(parent);
|
||||
seed_fmt(overlay_path(parent));
|
||||
|
||||
REQUIRE(cmd_add(root, "fmt", "10.2.0", {}, overlay_path(parent)).has_value());
|
||||
|
||||
@@ -112,13 +115,3 @@ TEST_CASE("cmd_add rejects an already-declared dep", "[cli][add]") {
|
||||
REQUIRE_FALSE(r.has_value());
|
||||
REQUIRE(r.error().code == ErrorCode::ManifestInvalidField);
|
||||
}
|
||||
|
||||
TEST_CASE("cmd_add rejects componentized package without components",
|
||||
"[cli][add]") {
|
||||
auto parent = fresh_dir();
|
||||
auto root = scaffold(parent);
|
||||
|
||||
auto r = cmd_add(root, "abseil-cpp", "20240116.0", {}, overlay_path(parent));
|
||||
REQUIRE_FALSE(r.has_value());
|
||||
REQUIRE(r.error().code == ErrorCode::LinkdbComponentNotSupported);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user