1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-08 19:46:02 +01:00

Declare DummyStoreConfig in a header

This will useful for unit tests.
This commit is contained in:
John Ericson 2025-09-17 15:20:42 -04:00
parent 613de9d9cc
commit 168c24b605
3 changed files with 47 additions and 38 deletions

View file

@ -1,48 +1,15 @@
#include "nix/store/store-registration.hh"
#include "nix/util/callback.hh"
#include "nix/store/dummy-store.hh"
namespace nix {
struct DummyStoreConfig : public std::enable_shared_from_this<DummyStoreConfig>, virtual StoreConfig
std::string DummyStoreConfig::doc()
{
using StoreConfig::StoreConfig;
DummyStoreConfig(std::string_view scheme, std::string_view authority, const Params & params)
: StoreConfig(params)
{
if (!authority.empty())
throw UsageError("`%s` store URIs must not contain an authority part %s", scheme, authority);
}
static const std::string name()
{
return "Dummy Store";
}
static std::string doc()
{
return
return
#include "dummy-store.md"
;
}
static StringSet uriSchemes()
{
return {"dummy"};
}
ref<Store> openStore() const override;
StoreReference getReference() const override
{
return {
.variant =
StoreReference::Specified{
.scheme = *uriSchemes().begin(),
},
};
}
};
;
}
struct DummyStore : virtual Store
{

View file

@ -0,0 +1,41 @@
#include "nix/store/store-api.hh"
namespace nix {
struct DummyStoreConfig : public std::enable_shared_from_this<DummyStoreConfig>, virtual StoreConfig
{
using StoreConfig::StoreConfig;
DummyStoreConfig(std::string_view scheme, std::string_view authority, const Params & params)
: StoreConfig(params)
{
if (!authority.empty())
throw UsageError("`%s` store URIs must not contain an authority part %s", scheme, authority);
}
static const std::string name()
{
return "Dummy Store";
}
static std::string doc();
static StringSet uriSchemes()
{
return {"dummy"};
}
ref<Store> openStore() const override;
StoreReference getReference() const override
{
return {
.variant =
StoreReference::Specified{
.scheme = *uriSchemes().begin(),
},
};
}
};
} // namespace nix

View file

@ -34,6 +34,7 @@ headers = [ config_pub_h ] + files(
'derived-path-map.hh',
'derived-path.hh',
'downstream-placeholder.hh',
'dummy-store.hh',
'export-import.hh',
'filetransfer.hh',
'gc-store.hh',