-
-
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.
Proper
parse
and render
functions for FileIngestionMethod
and `…
…ContentAddressMethod` No outward facing behavior is changed. Older methods with same names that operate on on method + algo pair (for old-style `<method>:algo`) are renamed to `*WithAlgo`.) The functions are unit-tested in the same way the names for the hash algorithms are tested.
- Loading branch information
1 parent
fb5a438
commit 41dd985
Showing
10 changed files
with
162 additions
and
30 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
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); | ||
} | ||
|
||
} |