+18
-4
@@ -29,6 +29,8 @@
|
||||
#include <vamp_zero/health.hpp>
|
||||
#include <vamp_zero/portal.hpp>
|
||||
|
||||
#include "catalogue_fixture.hpp"
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -184,6 +186,7 @@ auto make_assets(vamp_zero::config const &config) -> void {
|
||||
write_score(root / "songs" / "second.json");
|
||||
write_score(root / "practice" / "melody" / "lesson" / "exercise" / "c.json");
|
||||
write_score(root / "practice" / "melody" / "lesson" / "exercise" / "d.json", "D");
|
||||
BOOST_REQUIRE(vamp_test::build_catalogue(root, config.database.path));
|
||||
}
|
||||
|
||||
auto run_once(std::filesystem::path const &root, vamp_zero::config const &config) -> std::expected<void, modulus::error> {
|
||||
@@ -330,18 +333,26 @@ BOOST_AUTO_TEST_CASE(portal_remote_commands_refresh_connection_without_backgroun
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(readiness_imports_catalogue_without_hardware_or_heartbeat) {
|
||||
BOOST_AUTO_TEST_CASE(readiness_reads_packaged_catalogue_without_hardware_or_heartbeat) {
|
||||
auto root = temporary_directory{};
|
||||
auto config = fixture_config(root.path);
|
||||
make_assets(config);
|
||||
auto database_time = std::filesystem::last_write_time(config.database.path);
|
||||
for (auto const &entry : std::filesystem::recursive_directory_iterator{config.runtime.assets_path}) {
|
||||
if (entry.path().extension() == ".json") {
|
||||
std::filesystem::remove(entry.path());
|
||||
}
|
||||
}
|
||||
auto ready = run_once(root.path, config);
|
||||
BOOST_REQUIRE_MESSAGE(ready, (ready ? "" : ready.error().describe()));
|
||||
BOOST_TEST(std::filesystem::exists(config.database.path));
|
||||
BOOST_TEST((std::filesystem::last_write_time(config.database.path) == database_time));
|
||||
BOOST_TEST(!std::filesystem::exists(config.database.path + "-wal"));
|
||||
BOOST_TEST(!std::filesystem::exists(config.runtime.heartbeat_path));
|
||||
require_no_probe(config);
|
||||
auto io = boost::asio::io_context{};
|
||||
auto performance = boost::asio::co_spawn(io, vamp_zero::async_load_performance_library(io.get_executor(), config.database), boost::asio::use_future);
|
||||
auto practice = boost::asio::co_spawn(io, vamp_zero::async_load_practice_library(io.get_executor(), config.database), boost::asio::use_future);
|
||||
auto performance = boost::asio::co_spawn(io, vamp_zero::async_load_performance_library(io.get_executor(), config.database, config.runtime.assets_path), boost::asio::use_future);
|
||||
auto practice = boost::asio::co_spawn(io, vamp_zero::async_load_practice_library(io.get_executor(), config.database, config.runtime.assets_path), boost::asio::use_future);
|
||||
io.run();
|
||||
auto songs = performance.get();
|
||||
auto exercises = practice.get();
|
||||
@@ -385,6 +396,7 @@ BOOST_AUTO_TEST_CASE(readiness_validates_generated_audio_using_configured_asset_
|
||||
auto score = boost::json::parse(read_file(path));
|
||||
score.as_object()["playback"] = boost::json::parse(read_file(fixture / "score.json")).at("playback");
|
||||
write_file(path, boost::json::serialize(score));
|
||||
BOOST_REQUIRE(vamp_test::build_catalogue(assets, config.database.path));
|
||||
auto ready = run_once(root.path, config);
|
||||
BOOST_REQUIRE_MESSAGE(ready, (ready ? "" : ready.error().describe()));
|
||||
auto &sample = score.at("playback").at("samples").as_array().front().as_object();
|
||||
@@ -394,6 +406,7 @@ BOOST_AUTO_TEST_CASE(readiness_validates_generated_audio_using_configured_asset_
|
||||
sample["sha256"] = checksum(corrupt);
|
||||
write_file(audio, corrupt);
|
||||
write_file(path, boost::json::serialize(score));
|
||||
BOOST_REQUIRE(vamp_test::build_catalogue(assets, config.database.path));
|
||||
ready = run_once(root.path, config);
|
||||
BOOST_REQUIRE(!ready);
|
||||
BOOST_TEST(std::string{ready.error().message()}.find("PCM16 WAV") != std::string::npos);
|
||||
@@ -426,7 +439,7 @@ BOOST_AUTO_TEST_CASE(readiness_rejects_missing_or_malformed_catalogues) {
|
||||
auto config = fixture_config(root.path);
|
||||
BOOST_TEST(!run_once(root.path, config));
|
||||
make_assets(config);
|
||||
write_file(std::filesystem::path{config.runtime.assets_path} / "songs" / "first.json", "not JSON");
|
||||
write_file(config.database.path, "not a database");
|
||||
BOOST_TEST(!run_once(root.path, config));
|
||||
BOOST_TEST(!std::filesystem::exists(config.runtime.heartbeat_path));
|
||||
}
|
||||
@@ -463,6 +476,7 @@ BOOST_AUTO_TEST_CASE(readiness_decodes_pages_even_when_checksums_match) {
|
||||
write_file(score_path.parent_path() / std::string{page.at("path").as_string()}, bytes);
|
||||
page["sha256"] = checksum(bytes);
|
||||
write_file(score_path, boost::json::serialize(score));
|
||||
BOOST_REQUIRE(vamp_test::build_catalogue(config.runtime.assets_path, config.database.path));
|
||||
auto ready = run_once(root.path, config);
|
||||
BOOST_REQUIRE_MESSAGE(!ready, kind);
|
||||
BOOST_TEST(ready.error().describe().find("first.pages/1.png") != std::string::npos);
|
||||
|
||||
Reference in New Issue
Block a user