Jan_31_2024-Dev

This commit is contained in:
Ned Wright
2024-01-31 17:34:53 +00:00
parent 752a5785f0
commit 6d67818a94
376 changed files with 8101 additions and 7064 deletions

View File

@@ -73,7 +73,7 @@ TEST_F(PackageTest, serializationFromString)
EXPECT_EQ("orchestration", package.getName());
EXPECT_EQ("c", package.getVersion());
EXPECT_EQ(Package::PackageType::Service, package.getType());
EXPECT_TRUE(package.isInstallable().ok());
EXPECT_TRUE(package.isInstallable());
}
TEST_F(PackageTest, writeAsJson)
@@ -86,7 +86,8 @@ TEST_F(PackageTest, writeAsJson)
" \"name\": \"orchestration\",\n"
" \"checksum-type\": \"sha1sum\",\n"
" \"checksum\": \"8d4a5709673a05b380ba7d6567e28910019118f5\",\n"
" \"package-type\": \"service\"\n"
" \"package-type\": \"service\",\n"
" \"status\": true\n"
"}";
Package package;
EXPECT_EQ(true, load(string_stream, package));
@@ -99,7 +100,7 @@ TEST_F(PackageTest, writeAsJson)
EXPECT_EQ("orchestration", package.getName());
EXPECT_EQ("c", package.getVersion());
EXPECT_EQ(Package::PackageType::Service, package.getType());
EXPECT_TRUE(package.isInstallable().ok());
EXPECT_TRUE(package.isInstallable());
write("service.json", package);
string data = readFile("service.json");
@@ -232,5 +233,6 @@ TEST_F(PackageTest, uninstallablePackage)
"}";
Package package;
EXPECT_TRUE(load(string_stream, package));
EXPECT_THAT(package.isInstallable(), IsError("This security app isn't valid for this agent"));
EXPECT_FALSE(package.isInstallable());
EXPECT_EQ(package.getErrorMessage(), "This security app isn't valid for this agent");
}

View File

@@ -59,9 +59,9 @@ Package::serialize(JSONOutputArchive & out_archive) const
out_archive(make_nvp("require", require_packages));
}
if (!installable.ok()) {
out_archive(make_nvp("status", installable.ok()));
out_archive(make_nvp("message", installable.getErr()));
out_archive(make_nvp("status", installable));
if (!installable) {
out_archive(make_nvp("message", error_message));
}
}
@@ -89,21 +89,18 @@ Package::serialize(JSONInputArchive & in_archive)
in_archive.setNextName(nullptr);
}
bool is_installable = true;
try {
in_archive(make_nvp("status", is_installable));
in_archive(make_nvp("status", installable));
} catch (...) {
in_archive.setNextName(nullptr);
}
if (!is_installable) {
string error_message;
if (!installable) {
try {
in_archive(make_nvp("message", error_message));
} catch (...) {
in_archive.setNextName(nullptr);
}
installable = genError(error_message);
}
for (auto &character : name) {