Skip to content

Commit 168c24b

Browse files
committed
Declare DummyStoreConfig in a header
This will useful for unit tests.
1 parent 613de9d commit 168c24b

File tree

3 files changed

+47
-38
lines changed

3 files changed

+47
-38
lines changed

src/libstore/dummy-store.cc

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,15 @@
11
#include "nix/store/store-registration.hh"
22
#include "nix/util/callback.hh"
3+
#include "nix/store/dummy-store.hh"
34

45
namespace nix {
56

6-
struct DummyStoreConfig : public std::enable_shared_from_this<DummyStoreConfig>, virtual StoreConfig
7+
std::string DummyStoreConfig::doc()
78
{
8-
using StoreConfig::StoreConfig;
9-
10-
DummyStoreConfig(std::string_view scheme, std::string_view authority, const Params & params)
11-
: StoreConfig(params)
12-
{
13-
if (!authority.empty())
14-
throw UsageError("`%s` store URIs must not contain an authority part %s", scheme, authority);
15-
}
16-
17-
static const std::string name()
18-
{
19-
return "Dummy Store";
20-
}
21-
22-
static std::string doc()
23-
{
24-
return
9+
return
2510
#include "dummy-store.md"
26-
;
27-
}
28-
29-
static StringSet uriSchemes()
30-
{
31-
return {"dummy"};
32-
}
33-
34-
ref<Store> openStore() const override;
35-
36-
StoreReference getReference() const override
37-
{
38-
return {
39-
.variant =
40-
StoreReference::Specified{
41-
.scheme = *uriSchemes().begin(),
42-
},
43-
};
44-
}
45-
};
11+
;
12+
}
4613

4714
struct DummyStore : virtual Store
4815
{
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include "nix/store/store-api.hh"
2+
3+
namespace nix {
4+
5+
struct DummyStoreConfig : public std::enable_shared_from_this<DummyStoreConfig>, virtual StoreConfig
6+
{
7+
using StoreConfig::StoreConfig;
8+
9+
DummyStoreConfig(std::string_view scheme, std::string_view authority, const Params & params)
10+
: StoreConfig(params)
11+
{
12+
if (!authority.empty())
13+
throw UsageError("`%s` store URIs must not contain an authority part %s", scheme, authority);
14+
}
15+
16+
static const std::string name()
17+
{
18+
return "Dummy Store";
19+
}
20+
21+
static std::string doc();
22+
23+
static StringSet uriSchemes()
24+
{
25+
return {"dummy"};
26+
}
27+
28+
ref<Store> openStore() const override;
29+
30+
StoreReference getReference() const override
31+
{
32+
return {
33+
.variant =
34+
StoreReference::Specified{
35+
.scheme = *uriSchemes().begin(),
36+
},
37+
};
38+
}
39+
};
40+
41+
} // namespace nix

src/libstore/include/nix/store/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ headers = [ config_pub_h ] + files(
3434
'derived-path-map.hh',
3535
'derived-path.hh',
3636
'downstream-placeholder.hh',
37+
'dummy-store.hh',
3738
'export-import.hh',
3839
'filetransfer.hh',
3940
'gc-store.hh',

0 commit comments

Comments
 (0)