1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 02:21:16 +02:00

Merge pull request #13094 from xokdvium/file-content-address-fmt-string

libutil: Add missing format arguments to UsageError ctor
This commit is contained in:
Eelco Dolstra 2025-04-25 15:21:57 +02:00 committed by GitHub
commit 3f811c2373
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 6 deletions

View file

@ -1,3 +1,4 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "nix/util/file-content-address.hh"
@ -26,8 +27,11 @@ TEST(FileSerialisationMethod, testRoundTripPrintParse_2) {
}
}
TEST(FileSerialisationMethod, testParseFileSerialisationMethodOptException) {
EXPECT_THROW(parseFileSerialisationMethod("narwhal"), UsageError);
TEST(FileSerialisationMethod, testParseFileSerialisationMethodOptException)
{
EXPECT_THAT(
[]() { parseFileSerialisationMethod("narwhal"); },
testing::ThrowsMessage<UsageError>(testing::HasSubstr("narwhal")));
}
/* ----------------------------------------------------------------------------
@ -54,8 +58,11 @@ TEST(FileIngestionMethod, testRoundTripPrintParse_2) {
}
}
TEST(FileIngestionMethod, testParseFileIngestionMethodOptException) {
EXPECT_THROW(parseFileIngestionMethod("narwhal"), UsageError);
TEST(FileIngestionMethod, testParseFileIngestionMethodOptException)
{
EXPECT_THAT(
[]() { parseFileIngestionMethod("narwhal"); },
testing::ThrowsMessage<UsageError>(testing::HasSubstr("narwhal")));
}
}

View file

@ -22,7 +22,7 @@ FileSerialisationMethod parseFileSerialisationMethod(std::string_view input)
if (ret)
return *ret;
else
throw UsageError("Unknown file serialiation method '%s', expect `flat` or `nar`");
throw UsageError("Unknown file serialiation method '%s', expect `flat` or `nar`", input);
}
@ -35,7 +35,7 @@ FileIngestionMethod parseFileIngestionMethod(std::string_view input)
if (ret)
return static_cast<FileIngestionMethod>(*ret);
else
throw UsageError("Unknown file ingestion method '%s', expect `flat`, `nar`, or `git`");
throw UsageError("Unknown file ingestion method '%s', expect `flat`, `nar`, or `git`", input);
}
}