2024-02-13 16:54:07 +02:00
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
|
|
#include "content-address.hh"
|
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------------
|
|
|
|
* ContentAddressMethod::parse, ContentAddressMethod::render
|
|
|
|
* --------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
TEST(ContentAddressMethod, testRoundTripPrintParse_1) {
|
|
|
|
for (const ContentAddressMethod & cam : {
|
|
|
|
ContentAddressMethod { TextIngestionMethod {} },
|
|
|
|
ContentAddressMethod { FileIngestionMethod::Flat },
|
|
|
|
ContentAddressMethod { FileIngestionMethod::Recursive },
|
2023-09-04 16:51:23 +03:00
|
|
|
ContentAddressMethod { FileIngestionMethod::Git },
|
2024-02-13 16:54:07 +02:00
|
|
|
}) {
|
|
|
|
EXPECT_EQ(ContentAddressMethod::parse(cam.render()), cam);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(ContentAddressMethod, testRoundTripPrintParse_2) {
|
|
|
|
for (const std::string_view camS : {
|
|
|
|
"text",
|
|
|
|
"flat",
|
|
|
|
"nar",
|
2023-09-04 16:51:23 +03:00
|
|
|
"git",
|
2024-02-13 16:54:07 +02:00
|
|
|
}) {
|
|
|
|
EXPECT_EQ(ContentAddressMethod::parse(camS).render(), camS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(ContentAddressMethod, testParseContentAddressMethodOptException) {
|
|
|
|
EXPECT_THROW(ContentAddressMethod::parse("narwhal"), UsageError);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|