-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10009 from obsidiansystems/ca-type-names
Proper `parse` and `render` functions for `FileIngestionMethod` and `ContentAddressMethod`
- Loading branch information
Showing
11 changed files
with
164 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#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 }, | ||
}) { | ||
EXPECT_EQ(ContentAddressMethod::parse(cam.render()), cam); | ||
} | ||
} | ||
|
||
TEST(ContentAddressMethod, testRoundTripPrintParse_2) { | ||
for (const std::string_view camS : { | ||
"text", | ||
"flat", | ||
"nar", | ||
}) { | ||
EXPECT_EQ(ContentAddressMethod::parse(camS).render(), camS); | ||
} | ||
} | ||
|
||
TEST(ContentAddressMethod, testParseContentAddressMethodOptException) { | ||
EXPECT_THROW(ContentAddressMethod::parse("narwhal"), UsageError); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <gtest/gtest.h> | ||
|
||
#include "file-content-address.hh" | ||
|
||
namespace nix { | ||
|
||
/* ---------------------------------------------------------------------------- | ||
* parseFileIngestionMethod, renderFileIngestionMethod | ||
* --------------------------------------------------------------------------*/ | ||
|
||
TEST(FileIngestionMethod, testRoundTripPrintParse_1) { | ||
for (const FileIngestionMethod fim : { | ||
FileIngestionMethod::Flat, | ||
FileIngestionMethod::Recursive, | ||
}) { | ||
EXPECT_EQ(parseFileIngestionMethod(renderFileIngestionMethod(fim)), fim); | ||
} | ||
} | ||
|
||
TEST(FileIngestionMethod, testRoundTripPrintParse_2) { | ||
for (const std::string_view fimS : { | ||
"flat", | ||
"nar", | ||
}) { | ||
EXPECT_EQ(renderFileIngestionMethod(parseFileIngestionMethod(fimS)), fimS); | ||
} | ||
} | ||
|
||
TEST(FileIngestionMethod, testParseFileIngestionMethodOptException) { | ||
EXPECT_THROW(parseFileIngestionMethod("narwhal"), UsageError); | ||
} | ||
|
||
} |