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