mirror of
https://github.com/NixOS/nix.git
synced 2025-11-08 19:46:02 +01:00
libstore: Make all StoreConfig::getReference implementations return store parameters
These stragglers have been accidentally left out when implementing the StoreConfig::getReference. Also HttpBinaryCacheStore::getReference now returns the actual store parameters, not the cacheUri parameters.
This commit is contained in:
parent
3bf1268ac6
commit
426a72c9cf
6 changed files with 44 additions and 2 deletions
|
|
@ -18,4 +18,20 @@ TEST(HttpBinaryCacheStore, constructConfigNoTrailingSlash)
|
||||||
EXPECT_EQ(config.cacheUri.to_string(), "https://foo.bar.baz/a/b");
|
EXPECT_EQ(config.cacheUri.to_string(), "https://foo.bar.baz/a/b");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(HttpBinaryCacheStore, constructConfigWithParams)
|
||||||
|
{
|
||||||
|
StoreConfig::Params params{{"compression", "xz"}};
|
||||||
|
HttpBinaryCacheStoreConfig config{"https", "foo.bar.baz/a/b/", params};
|
||||||
|
EXPECT_EQ(config.cacheUri.to_string(), "https://foo.bar.baz/a/b");
|
||||||
|
EXPECT_EQ(config.getReference().params, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(HttpBinaryCacheStore, constructConfigWithParamsAndUrlWithParams)
|
||||||
|
{
|
||||||
|
StoreConfig::Params params{{"compression", "xz"}};
|
||||||
|
HttpBinaryCacheStoreConfig config{"https", "foo.bar.baz/a/b?some-param=some-value", params};
|
||||||
|
EXPECT_EQ(config.cacheUri.to_string(), "https://foo.bar.baz/a/b?some-param=some-value");
|
||||||
|
EXPECT_EQ(config.getReference().params, params);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace nix
|
} // namespace nix
|
||||||
|
|
|
||||||
|
|
@ -22,4 +22,24 @@ TEST(UDSRemoteStore, constructConfig_to_string)
|
||||||
EXPECT_EQ(config.getReference().to_string(), "daemon");
|
EXPECT_EQ(config.getReference().to_string(), "daemon");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(UDSRemoteStore, constructConfigWithParams)
|
||||||
|
{
|
||||||
|
StoreConfig::Params params{{"max-connections", "1"}};
|
||||||
|
UDSRemoteStoreConfig config{"unix", "/tmp/socket", params};
|
||||||
|
auto storeReference = config.getReference();
|
||||||
|
EXPECT_EQ(storeReference.to_string(), "unix:///tmp/socket?max-connections=1");
|
||||||
|
EXPECT_EQ(storeReference.render(/*withParams=*/false), "unix:///tmp/socket");
|
||||||
|
EXPECT_EQ(storeReference.params, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(UDSRemoteStore, constructConfigWithParamsNoPath)
|
||||||
|
{
|
||||||
|
StoreConfig::Params params{{"max-connections", "1"}};
|
||||||
|
UDSRemoteStoreConfig config{"unix", "", params};
|
||||||
|
auto storeReference = config.getReference();
|
||||||
|
EXPECT_EQ(storeReference.to_string(), "daemon?max-connections=1");
|
||||||
|
EXPECT_EQ(storeReference.render(/*withParams=*/false), "daemon");
|
||||||
|
EXPECT_EQ(storeReference.params, params);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace nix
|
} // namespace nix
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ StoreReference HttpBinaryCacheStoreConfig::getReference() const
|
||||||
.scheme = cacheUri.scheme,
|
.scheme = cacheUri.scheme,
|
||||||
.authority = cacheUri.renderAuthorityAndPath(),
|
.authority = cacheUri.renderAuthorityAndPath(),
|
||||||
},
|
},
|
||||||
.params = cacheUri.query,
|
.params = getQueryParams(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ struct DummyStoreConfig : public std::enable_shared_from_this<DummyStoreConfig>,
|
||||||
StoreReference::Specified{
|
StoreReference::Specified{
|
||||||
.scheme = *uriSchemes().begin(),
|
.scheme = *uriSchemes().begin(),
|
||||||
},
|
},
|
||||||
|
.params = getQueryParams(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -262,6 +262,7 @@ StoreReference S3BinaryCacheStoreConfig::getReference() const
|
||||||
.scheme = *uriSchemes().begin(),
|
.scheme = *uriSchemes().begin(),
|
||||||
.authority = bucketName,
|
.authority = bucketName,
|
||||||
},
|
},
|
||||||
|
.params = getQueryParams(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,13 +61,17 @@ StoreReference UDSRemoteStoreConfig::getReference() const
|
||||||
* to be more compatible with older versions of nix. Some tooling out there
|
* to be more compatible with older versions of nix. Some tooling out there
|
||||||
* tries hard to parse store references and it might not be able to handle "unix://". */
|
* tries hard to parse store references and it might not be able to handle "unix://". */
|
||||||
if (path == settings.nixDaemonSocketFile)
|
if (path == settings.nixDaemonSocketFile)
|
||||||
return {.variant = StoreReference::Daemon{}};
|
return {
|
||||||
|
.variant = StoreReference::Daemon{},
|
||||||
|
.params = getQueryParams(),
|
||||||
|
};
|
||||||
return {
|
return {
|
||||||
.variant =
|
.variant =
|
||||||
StoreReference::Specified{
|
StoreReference::Specified{
|
||||||
.scheme = *uriSchemes().begin(),
|
.scheme = *uriSchemes().begin(),
|
||||||
.authority = path,
|
.authority = path,
|
||||||
},
|
},
|
||||||
|
.params = getQueryParams(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue