Skip to content

Commit

Permalink
Update tests given XP feature checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Ericson2314 committed Feb 3, 2025
1 parent c431542 commit 01d1acc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
8 changes: 8 additions & 0 deletions src/libstore-tests/ssh-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ TEST(SSHStore, constructConfig)

TEST(MountedSSHStore, constructConfig)
{
ExperimentalFeatureSettings mockXpSettings;
mockXpSettings.set("experimental-features", "mounted-ssh-store");

SSHStoreConfig config{
"ssh-ng",
"localhost",
Expand All @@ -46,6 +49,7 @@ TEST(MountedSSHStore, constructConfig)
nlohmann::json::object_t{},
},
},
mockXpSettings,
};

EXPECT_EQ(
Expand All @@ -62,6 +66,9 @@ TEST(MountedSSHStore, constructConfig)

TEST(MountedSSHStore, constructConfigWithFunnyRealStoreDir)
{
ExperimentalFeatureSettings mockXpSettings;
mockXpSettings.set("experimental-features", "mounted-ssh-store");

SSHStoreConfig config{
"ssh-ng",
"localhost",
Expand All @@ -80,6 +87,7 @@ TEST(MountedSSHStore, constructConfigWithFunnyRealStoreDir)
},
},
},
mockXpSettings,
};

EXPECT_EQ(
Expand Down
9 changes: 5 additions & 4 deletions src/libstore/ssh-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,13 @@ config::SettingDescriptionMap SSHStoreConfig::descriptions()

static std::optional<LocalFSStore::Config> getMounted(
const Store::Config & storeConfig,
const StoreReference::Params & params)
const StoreReference::Params & params,
const ExperimentalFeatureSettings & xpSettings)
{
auto mountedParamsOpt = optionalValueAt(params, "mounted");
if (!mountedParamsOpt) return {};
auto * mountedParamsP = getNullable(*mountedParamsOpt);
experimentalFeatureSettings.require(Xp::MountedSSHStore);
xpSettings.require(Xp::MountedSSHStore);
if (!mountedParamsP) return {};
auto & mountedParams = getObject(*mountedParamsP);
return {{storeConfig, mountedParams}};
Expand All @@ -96,12 +97,12 @@ static std::optional<LocalFSStore::Config> getMounted(
SSHStoreConfig::SSHStoreConfig(
std::string_view scheme,
std::string_view authority,
const StoreReference::Params & params)
const StoreReference::Params & params, const ExperimentalFeatureSettings & xpSettings)
: Store::Config{params}
, RemoteStore::Config{*this, params}
, CommonSSHStoreConfig{scheme, authority, params}
, SSHStoreConfigT<config::JustValue>{sshStoreConfigApplyParse(params)}
, mounted{getMounted(*this, params)}
, mounted{getMounted(*this, params, xpSettings)}
{
}

Expand Down
6 changes: 5 additions & 1 deletion src/libstore/ssh-store.hh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ struct SSHStoreConfig : std::enable_shared_from_this<SSHStoreConfig>,

std::optional<LocalFSStore::Config> mounted;

SSHStoreConfig(std::string_view scheme, std::string_view authority, const StoreReference::Params & params);
SSHStoreConfig(
std::string_view scheme,
std::string_view authority,
const StoreReference::Params & params,
const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);

static const std::string name()
{
Expand Down

0 comments on commit 01d1acc

Please sign in to comment.