feat(registry,daemon): honour If-None-Match; allow offline deps resolution
This commit is contained in:
1 parent
c6436a8010
commit
fdfab9277b
8 files changed
+140
-19
No files matched your search
@@ -438,6 +438,22 @@ void build(Void::Build::Project &project) {
|
||||
Void::Testing::expect_eq(str_field(*first_dep, "source_kind"), std::string{"path"});
|
||||
Void::Testing::expect(!str_field(*first_dep, "sha256").empty());
|
||||
|
||||
auto offline_deps =
|
||||
request_object(socket, R"({"op":"deps","offline":true})", std::chrono::seconds{120});
|
||||
Void::Testing::require(offline_deps.has_value());
|
||||
Void::Testing::expect(bool_field(*offline_deps, "ok"));
|
||||
Void::Testing::expect_eq(str_field(*offline_deps, "op"), std::string{"deps"});
|
||||
const auto *offline_entries = field(*offline_deps, "entries");
|
||||
Void::Testing::require(offline_entries != nullptr);
|
||||
const auto *offline_array = std::get_if<JsonValue::Array>(&offline_entries->value);
|
||||
Void::Testing::require(offline_array != nullptr && !offline_array->empty());
|
||||
|
||||
auto invalid_offline = request_object(socket, R"({"op":"deps","offline":"yes"})");
|
||||
Void::Testing::require(invalid_offline.has_value());
|
||||
Void::Testing::expect(!bool_field(*invalid_offline, "ok", true));
|
||||
Void::Testing::expect(str_field(*invalid_offline, "error").find("boolean") !=
|
||||
std::string::npos);
|
||||
|
||||
auto build = request_object(socket, R"({"op":"build"})", std::chrono::seconds{120});
|
||||
Void::Testing::require(build.has_value());
|
||||
Void::Testing::expect(bool_field(*build, "ok"));
|
||||
@@ -451,6 +467,55 @@ void build(Void::Build::Project &project) {
|
||||
Void::Testing::expect(run_result.has_value());
|
||||
}
|
||||
|
||||
VOID_TEST(Daemon, deps_offline_reports_uncached_registry_dependency) {
|
||||
auto temp = Void::FileSystem::TempDir::open("vbs_daemon_");
|
||||
Void::Testing::require(temp.has_value());
|
||||
const auto options = make_options(temp->path());
|
||||
|
||||
{
|
||||
std::ofstream descriptor{options.project_root / "build.cpp"};
|
||||
descriptor << R"cpp(#include <Void/Build.hpp>
|
||||
|
||||
void build(Void::Build::Project &project) {
|
||||
project.dependency("remote")
|
||||
.package("remote-pkg", "^1.0")
|
||||
.registry("http://127.0.0.1:1");
|
||||
auto app = project.executable("app");
|
||||
app.sources({"main.cpp"});
|
||||
}
|
||||
)cpp";
|
||||
Void::Testing::require(descriptor.good());
|
||||
}
|
||||
{
|
||||
std::ofstream source{options.project_root / "main.cpp"};
|
||||
source << "int main() { return 0; }\n";
|
||||
Void::Testing::require(source.good());
|
||||
}
|
||||
|
||||
auto server = Void::Build::Daemon::DaemonServer::create(options);
|
||||
Void::Testing::require(server.has_value());
|
||||
const auto socket = server->socket_path();
|
||||
|
||||
Void::Result::Result<void, Void::Result::Error> run_result;
|
||||
std::jthread worker{[&] { run_result = server->run(); }};
|
||||
Void::Testing::require(wait_for_path(socket, std::chrono::seconds{5}));
|
||||
|
||||
// The package is not in the lock or cache, so offline resolution must fail before any
|
||||
// registry connection is attempted; a network error would mean `offline` was ignored.
|
||||
auto offline =
|
||||
request_object(socket, R"({"op":"deps","offline":true})", std::chrono::seconds{120});
|
||||
Void::Testing::require(offline.has_value());
|
||||
Void::Testing::expect(!bool_field(*offline, "ok", true));
|
||||
Void::Testing::expect(
|
||||
str_field(*offline, "error").find("offline mode cannot query live package registry") !=
|
||||
std::string::npos);
|
||||
|
||||
auto shutdown = Void::Build::Daemon::request(socket, R"({"op":"shutdown"})");
|
||||
Void::Testing::expect(shutdown.has_value());
|
||||
worker.join();
|
||||
Void::Testing::expect(run_result.has_value());
|
||||
}
|
||||
|
||||
VOID_TEST(Daemon, ide_query_serves_workspace_targets_and_compdb) {
|
||||
auto temp = Void::FileSystem::TempDir::open("vbs_daemon_");
|
||||
Void::Testing::require(temp.has_value());
|
||||
|
||||
Reference in new issue
Block a user