NAME
Net::Blossom::Server::Storage::Test - Conformance tests for Blossom server storage backends
SYNOPSIS
use Net::Blossom::Server::Storage::Test qw(run_storage_contract_tests);
run_storage_contract_tests(
name => 'postgres storage',
factory => sub {
reset_test_database($dbh);
return My::Blossom::Storage::Postgres->new(
dbh => $dbh,
base_url => 'https://cdn.example.test',
);
},
);
DESCRIPTION
Net::Blossom::Server::Storage::Test provides reusable tests for storage backend distributions. A backend can be database-backed, filesystem-backed, or object-storage-backed as long as it satisfies Net::Blossom::Server::Storage.
The test helper creates fresh storage instances with a caller-provided factory and verifies observable behavior through the public server and storage APIs.
FUNCTIONS
run_storage_contract_tests
run_storage_contract_tests(
name => $name,
factory => sub { ... },
);
Runs a Test::More subtest named $name. factory must return a fresh, empty storage object each time it is called. Persistent backends should delete test rows or files before returning the storage object.
The tests cover successful uploads, duplicate upload deduplication, retrieval, optional head_blob, failed upload abort behavior, owner-scoped deletion, shared blobs, list ordering, cursor pagination, unknown cursors, and limit handling.
STORAGE EXPECTATIONS
The storage object must implement the runtime contract documented by Net::Blossom::Server::Storage. In particular, list_blobs must return descriptors ordered by uploaded descending and sha256 ascending, and cursor must start the next page after the matching descriptor in that order.
Missing blobs return undef from get_blob and optional head_blob. delete_blob returns false when there is no matching blob or owner relationship. Failed uploads and aborted uploads must not become visible through get_blob or list_blobs.