[M5+] add resolver::nixpkgs_probe (nix eval wrapper)
This commit is contained in:
40
tests/nixpkgs_probe_live.cpp
Normal file
40
tests/nixpkgs_probe_live.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
// Network/nix-eval-gated integration test for resolver::nixpkgs_probe.
|
||||
// Skipped unless CARGOXX_NETWORK_TESTS=1 is set in the environment.
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
import cargoxx.resolver;
|
||||
import cargoxx.util;
|
||||
import std;
|
||||
|
||||
namespace {
|
||||
|
||||
auto network_tests_enabled() -> bool {
|
||||
auto* env = std::getenv("CARGOXX_NETWORK_TESTS");
|
||||
return env != nullptr && std::string_view{env} == "1";
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST_CASE("nixpkgs_probe finds 'hello'", "[resolver][network]") {
|
||||
if (!network_tests_enabled()) {
|
||||
SKIP("CARGOXX_NETWORK_TESTS != 1");
|
||||
}
|
||||
auto r = cargoxx::resolver::nixpkgs_probe("hello");
|
||||
REQUIRE(r.has_value());
|
||||
REQUIRE(r->attr == "hello");
|
||||
REQUIRE_FALSE(r->out_path.empty());
|
||||
REQUIRE(r->out_path.starts_with("/nix/store/"));
|
||||
// GNU hello has a stable, conventional version field.
|
||||
REQUIRE_FALSE(r->version.empty());
|
||||
}
|
||||
|
||||
TEST_CASE("nixpkgs_probe rejects an unknown attribute", "[resolver][network]") {
|
||||
if (!network_tests_enabled()) {
|
||||
SKIP("CARGOXX_NETWORK_TESTS != 1");
|
||||
}
|
||||
auto r = cargoxx::resolver::nixpkgs_probe(
|
||||
"definitely_not_a_real_pkg_cargoxx_xyzzy");
|
||||
REQUIRE_FALSE(r.has_value());
|
||||
REQUIRE(r.error().code == cargoxx::util::ErrorCode::ResolutionUnknownPackage);
|
||||
}
|
||||
Reference in New Issue
Block a user