2024-02-13 14:54:07 +00:00
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
|
|
#include "file-content-address.hh"
|
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
2023-09-04 13:51:23 +00:00
|
|
|
/* ----------------------------------------------------------------------------
|
|
|
|
* parseFileSerialisationMethod, renderFileSerialisationMethod
|
|
|
|
* --------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
TEST(FileSerialisationMethod, testRoundTripPrintParse_1) {
|
|
|
|
for (const FileSerialisationMethod fim : {
|
|
|
|
FileSerialisationMethod::Flat,
|
2024-05-16 21:46:43 +00:00
|
|
|
FileSerialisationMethod::NixArchive,
|
2023-09-04 13:51:23 +00:00
|
|
|
}) {
|
|
|
|
EXPECT_EQ(parseFileSerialisationMethod(renderFileSerialisationMethod(fim)), fim);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(FileSerialisationMethod, testRoundTripPrintParse_2) {
|
|
|
|
for (const std::string_view fimS : {
|
|
|
|
"flat",
|
|
|
|
"nar",
|
|
|
|
}) {
|
|
|
|
EXPECT_EQ(renderFileSerialisationMethod(parseFileSerialisationMethod(fimS)), fimS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(FileSerialisationMethod, testParseFileSerialisationMethodOptException) {
|
|
|
|
EXPECT_THROW(parseFileSerialisationMethod("narwhal"), UsageError);
|
|
|
|
}
|
|
|
|
|
2024-02-13 14:54:07 +00:00
|
|
|
/* ----------------------------------------------------------------------------
|
|
|
|
* parseFileIngestionMethod, renderFileIngestionMethod
|
|
|
|
* --------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
TEST(FileIngestionMethod, testRoundTripPrintParse_1) {
|
|
|
|
for (const FileIngestionMethod fim : {
|
|
|
|
FileIngestionMethod::Flat,
|
2024-05-16 21:46:43 +00:00
|
|
|
FileIngestionMethod::NixArchive,
|
2023-09-04 13:51:23 +00:00
|
|
|
FileIngestionMethod::Git,
|
2024-02-13 14:54:07 +00:00
|
|
|
}) {
|
|
|
|
EXPECT_EQ(parseFileIngestionMethod(renderFileIngestionMethod(fim)), fim);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(FileIngestionMethod, testRoundTripPrintParse_2) {
|
|
|
|
for (const std::string_view fimS : {
|
|
|
|
"flat",
|
|
|
|
"nar",
|
2023-09-04 13:51:23 +00:00
|
|
|
"git",
|
2024-02-13 14:54:07 +00:00
|
|
|
}) {
|
|
|
|
EXPECT_EQ(renderFileIngestionMethod(parseFileIngestionMethod(fimS)), fimS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(FileIngestionMethod, testParseFileIngestionMethodOptException) {
|
|
|
|
EXPECT_THROW(parseFileIngestionMethod("narwhal"), UsageError);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|