mirror of
https://github.com/aydencharles/onionHEN.git
synced 2026-10-22 11:53:07 -05:00
Replace the git clone/fetch pipeline with a curl + miniz HTTPS ZIP download. The engine streams one archive, extracts only the catalog roots, and reuses flatten to install flat files, so the libgit2 submodule and its build integration are gone. Drop the pre-download reachability probe and the commit-SHA parser; reachability is implied by the download itself and the SHA only fed the old git flow. Mirror selection stays in CheatMirrorFactory (auto: cnb.cool for zh-Hans, GitHub otherwise; explicit github/cnb skips fallback). curl verifies peer+host against the embedded CA bundle and now distinguishes certificate time-skew from other verification failures, surfacing a dedicated clock notification. Revert the util CMake target back to "util" now that libgit2 no longer claims that name.
55 lines
1.9 KiB
C++
55 lines
1.9 KiB
C++
#include "test_harness.h"
|
|
|
|
#include "cheats/sync/cheat_catalog_registry.hpp"
|
|
|
|
#include <cstring>
|
|
#include <string>
|
|
|
|
using onion::cheats::sync::CheatCatalogRegistry;
|
|
using onion::cheats::sync::CheatMirrorId;
|
|
|
|
static int test_primary_id_and_layout(void) {
|
|
const auto &cat = CheatCatalogRegistry::primary();
|
|
TEST_ASSERT_TRUE(cat.id() != nullptr);
|
|
TEST_ASSERT_TRUE(std::strchr(cat.id(), '/') == nullptr);
|
|
TEST_ASSERT_TRUE(cat.defaultBranch() != nullptr);
|
|
TEST_ASSERT_TRUE(cat.defaultBranch()[0] != '\0');
|
|
|
|
size_t n = 0;
|
|
const char *const *roots = cat.flattenRoots(&n);
|
|
TEST_ASSERT_TRUE(roots != nullptr);
|
|
TEST_ASSERT_TRUE(n >= 1);
|
|
TEST_ASSERT_STREQ("cheats", roots[0]);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int test_slug_is_owner_repo(void) {
|
|
const auto &cat = CheatCatalogRegistry::primary();
|
|
const char *gh = cat.slugFor(CheatMirrorId::Github);
|
|
const char *cnb = cat.slugFor(CheatMirrorId::Cnb);
|
|
TEST_ASSERT_TRUE(gh != nullptr && std::strchr(gh, '/') != nullptr);
|
|
TEST_ASSERT_TRUE(cnb != nullptr && std::strchr(cnb, '/') != nullptr);
|
|
TEST_ASSERT_TRUE(std::strstr(gh, "https://") == nullptr);
|
|
TEST_ASSERT_STREQ("TeeKay87/HEN-Cheats-Collection", gh);
|
|
TEST_ASSERT_STREQ("kylin-core/hen-cheats-cnb-mirror", cnb);
|
|
return 0;
|
|
}
|
|
|
|
static int test_registry_find(void) {
|
|
const auto &cat = CheatCatalogRegistry::primary();
|
|
TEST_ASSERT_TRUE(CheatCatalogRegistry::find(nullptr) == &cat);
|
|
TEST_ASSERT_TRUE(CheatCatalogRegistry::find("") == &cat);
|
|
TEST_ASSERT_TRUE(CheatCatalogRegistry::find(cat.id()) == &cat);
|
|
TEST_ASSERT_TRUE(CheatCatalogRegistry::find("no-such-catalog") == nullptr);
|
|
return 0;
|
|
}
|
|
|
|
extern "C" int test_cheat_catalog_suite(void) {
|
|
int fails = 0;
|
|
fails += onion_test_run("catalog.layout", test_primary_id_and_layout);
|
|
fails += onion_test_run("catalog.slug", test_slug_is_owner_repo);
|
|
fails += onion_test_run("catalog.find", test_registry_find);
|
|
return fails;
|
|
}
|