mirror of
https://github.com/NixOS/nix
synced 2025-06-27 08:31:16 +02:00
Cleanup ContentAddressMethod
to match docs
The old `std::variant` is bad because we aren't adding a new case to `FileIngestionMethod` so much as we are defining a separate concept --- store object content addressing rather than file system object content addressing. As such, it is more correct to just create a fresh enumeration. Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
This commit is contained in:
parent
64e599ebe1
commit
b51e161af5
25 changed files with 275 additions and 203 deletions
|
@ -83,15 +83,15 @@ CHARACTERIZATION_TEST(
|
|||
"content-address",
|
||||
(std::tuple<ContentAddress, ContentAddress, ContentAddress> {
|
||||
ContentAddress {
|
||||
.method = TextIngestionMethod {},
|
||||
.method = ContentAddressMethod::Raw::Text,
|
||||
.hash = hashString(HashAlgorithm::SHA256, "Derive(...)"),
|
||||
},
|
||||
ContentAddress {
|
||||
.method = FileIngestionMethod::Flat,
|
||||
.method = ContentAddressMethod::Raw::Flat,
|
||||
.hash = hashString(HashAlgorithm::SHA1, "blob blob..."),
|
||||
},
|
||||
ContentAddress {
|
||||
.method = FileIngestionMethod::NixArchive,
|
||||
.method = ContentAddressMethod::Raw::NixArchive,
|
||||
.hash = hashString(HashAlgorithm::SHA256, "(...)"),
|
||||
},
|
||||
}))
|
||||
|
@ -178,7 +178,7 @@ CHARACTERIZATION_TEST(
|
|||
std::nullopt,
|
||||
std::optional {
|
||||
ContentAddress {
|
||||
.method = FileIngestionMethod::Flat,
|
||||
.method = ContentAddressMethod::Raw::Flat,
|
||||
.hash = hashString(HashAlgorithm::SHA1, "blob blob..."),
|
||||
},
|
||||
},
|
||||
|
|
|
@ -9,11 +9,11 @@ namespace nix {
|
|||
* --------------------------------------------------------------------------*/
|
||||
|
||||
TEST(ContentAddressMethod, testRoundTripPrintParse_1) {
|
||||
for (const ContentAddressMethod & cam : {
|
||||
ContentAddressMethod { TextIngestionMethod {} },
|
||||
ContentAddressMethod { FileIngestionMethod::Flat },
|
||||
ContentAddressMethod { FileIngestionMethod::NixArchive },
|
||||
ContentAddressMethod { FileIngestionMethod::Git },
|
||||
for (ContentAddressMethod cam : {
|
||||
ContentAddressMethod::Raw::Text,
|
||||
ContentAddressMethod::Raw::Flat,
|
||||
ContentAddressMethod::Raw::NixArchive,
|
||||
ContentAddressMethod::Raw::Git,
|
||||
}) {
|
||||
EXPECT_EQ(ContentAddressMethod::parse(cam.render()), cam);
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ TEST_JSON(DerivationTest, inputAddressed,
|
|||
TEST_JSON(DerivationTest, caFixedFlat,
|
||||
(DerivationOutput::CAFixed {
|
||||
.ca = {
|
||||
.method = FileIngestionMethod::Flat,
|
||||
.method = ContentAddressMethod::Raw::Flat,
|
||||
.hash = Hash::parseAnyPrefixed("sha256-iUUXyRY8iW7DGirb0zwGgf1fRbLA7wimTJKgP7l/OQ8="),
|
||||
},
|
||||
}),
|
||||
|
@ -117,7 +117,7 @@ TEST_JSON(DerivationTest, caFixedFlat,
|
|||
TEST_JSON(DerivationTest, caFixedNAR,
|
||||
(DerivationOutput::CAFixed {
|
||||
.ca = {
|
||||
.method = FileIngestionMethod::NixArchive,
|
||||
.method = ContentAddressMethod::Raw::NixArchive,
|
||||
.hash = Hash::parseAnyPrefixed("sha256-iUUXyRY8iW7DGirb0zwGgf1fRbLA7wimTJKgP7l/OQ8="),
|
||||
},
|
||||
}),
|
||||
|
@ -126,6 +126,7 @@ TEST_JSON(DerivationTest, caFixedNAR,
|
|||
TEST_JSON(DynDerivationTest, caFixedText,
|
||||
(DerivationOutput::CAFixed {
|
||||
.ca = {
|
||||
.method = ContentAddressMethod::Raw::Text,
|
||||
.hash = Hash::parseAnyPrefixed("sha256-iUUXyRY8iW7DGirb0zwGgf1fRbLA7wimTJKgP7l/OQ8="),
|
||||
},
|
||||
}),
|
||||
|
@ -133,7 +134,7 @@ TEST_JSON(DynDerivationTest, caFixedText,
|
|||
|
||||
TEST_JSON(CaDerivationTest, caFloating,
|
||||
(DerivationOutput::CAFloating {
|
||||
.method = FileIngestionMethod::NixArchive,
|
||||
.method = ContentAddressMethod::Raw::NixArchive,
|
||||
.hashAlgo = HashAlgorithm::SHA256,
|
||||
}),
|
||||
"drv-name", "output-name")
|
||||
|
@ -144,7 +145,7 @@ TEST_JSON(DerivationTest, deferred,
|
|||
|
||||
TEST_JSON(ImpureDerivationTest, impure,
|
||||
(DerivationOutput::Impure {
|
||||
.method = FileIngestionMethod::NixArchive,
|
||||
.method = ContentAddressMethod::Raw::NixArchive,
|
||||
.hashAlgo = HashAlgorithm::SHA256,
|
||||
}),
|
||||
"drv-name", "output-name")
|
||||
|
|
|
@ -55,15 +55,15 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
defaultVersion,
|
||||
(std::tuple<ContentAddress, ContentAddress, ContentAddress> {
|
||||
ContentAddress {
|
||||
.method = TextIngestionMethod {},
|
||||
.method = ContentAddressMethod::Raw::Text,
|
||||
.hash = hashString(HashAlgorithm::SHA256, "Derive(...)"),
|
||||
},
|
||||
ContentAddress {
|
||||
.method = FileIngestionMethod::Flat,
|
||||
.method = ContentAddressMethod::Raw::Flat,
|
||||
.hash = hashString(HashAlgorithm::SHA1, "blob blob..."),
|
||||
},
|
||||
ContentAddress {
|
||||
.method = FileIngestionMethod::NixArchive,
|
||||
.method = ContentAddressMethod::Raw::NixArchive,
|
||||
.hash = hashString(HashAlgorithm::SHA256, "(...)"),
|
||||
},
|
||||
}))
|
||||
|
@ -398,7 +398,7 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
std::nullopt,
|
||||
std::optional {
|
||||
ContentAddress {
|
||||
.method = FileIngestionMethod::Flat,
|
||||
.method = ContentAddressMethod::Raw::Flat,
|
||||
.hash = hashString(HashAlgorithm::SHA1, "blob blob..."),
|
||||
},
|
||||
},
|
||||
|
|
|
@ -56,15 +56,15 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
defaultVersion,
|
||||
(std::tuple<ContentAddress, ContentAddress, ContentAddress> {
|
||||
ContentAddress {
|
||||
.method = TextIngestionMethod {},
|
||||
.method = ContentAddressMethod::Raw::Text,
|
||||
.hash = hashString(HashAlgorithm::SHA256, "Derive(...)"),
|
||||
},
|
||||
ContentAddress {
|
||||
.method = FileIngestionMethod::Flat,
|
||||
.method = ContentAddressMethod::Raw::Flat,
|
||||
.hash = hashString(HashAlgorithm::SHA1, "blob blob..."),
|
||||
},
|
||||
ContentAddress {
|
||||
.method = FileIngestionMethod::NixArchive,
|
||||
.method = ContentAddressMethod::Raw::NixArchive,
|
||||
.hash = hashString(HashAlgorithm::SHA256, "(...)"),
|
||||
},
|
||||
}))
|
||||
|
@ -598,7 +598,7 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
std::nullopt,
|
||||
std::optional {
|
||||
ContentAddress {
|
||||
.method = FileIngestionMethod::Flat,
|
||||
.method = ContentAddressMethod::Raw::Flat,
|
||||
.hash = hashString(HashAlgorithm::SHA1, "blob blob..."),
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue