summaryrefslogtreecommitdiff
path: root/p2pvr/daemon/unittests/testStorage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'p2pvr/daemon/unittests/testStorage.cpp')
-rw-r--r--p2pvr/daemon/unittests/testStorage.cpp45
1 files changed, 21 insertions, 24 deletions
diff --git a/p2pvr/daemon/unittests/testStorage.cpp b/p2pvr/daemon/unittests/testStorage.cpp
index ebbddcc..5083848 100644
--- a/p2pvr/daemon/unittests/testStorage.cpp
+++ b/p2pvr/daemon/unittests/testStorage.cpp
@@ -19,14 +19,11 @@ using namespace P2PVR::Testing;
const boost::filesystem::path storageRootDir = "/tmp/ut/p2pvr/recordings";
namespace P2PVR {
namespace Testing {
-class TestService : public PQ::Mock, public IceTray::DryIce {
+class TestService : public StandardMockDatabase {
public:
TestService() :
- PQ::Mock("user=postgres dbname=postgres", "postgres", {
- rootDir.parent_path().parent_path() / "datasources" / "schema.sql" }),
- IceTray::DryIce({
- R"C(--p2pvr.storage.muxercommand="")C",
- std::string("--p2pvr.storage.root=" + storageRootDir.string()),
+ StandardMockDatabase({
+ R"C(--p2pvr.storage.muxercommand="cat")C"
})
{
}
@@ -38,39 +35,39 @@ BOOST_GLOBAL_FIXTURE( TestService );
BOOST_FIXTURE_TEST_SUITE( StCore, TestClient );
-BOOST_AUTO_TEST_CASE( st_openWriteClose )
+static
+void
+runTest(RecordingsPrx recordings, StoragePrx storage)
{
- boost::filesystem::remove_all(storageRootDir);
- std::string id = "made-up-storage-id";
-
+ auto id = recordings->NewRecording(new Recording(0, 8, 2556));
auto rdc = storage->OpenForWrite(id);
BOOST_REQUIRE(rdc);
- P2PVR::Data data;
+ Data data;
data.resize(1024);
rdc->NewData(data);
storage->Close(rdc);
- auto stSize = storage->FileSize(id);
- BOOST_REQUIRE_EQUAL(1024, stSize);
- BOOST_REQUIRE_EQUAL(1024, boost::filesystem::file_size(storageRootDir / id));
+ BOOST_REQUIRE_EQUAL(1024, storage->GetSize(id));
- storage->Delete(id);
- BOOST_REQUIRE(!boost::filesystem::exists(storageRootDir / id));
+ recordings->DeleteRecording(id);
+ BOOST_REQUIRE_EQUAL(0, storage->GetSize(id));
}
-BOOST_AUTO_TEST_CASE( st_notuniqueid )
+BOOST_AUTO_TEST_CASE( st_openWriteCloseMuxWithCat )
{
- boost::filesystem::remove_all(storageRootDir);
- std::string id = "made-up-storage-id";
-
- auto rdc = storage->OpenForWrite(id);
- storage->Close(rdc);
+ IceTray::OptionsResolver<StorageI::Options> opts;
+ const_cast<std::string &>(opts->muxerCommand) = "/bin/cat";
+ runTest(recordings, storage);
+}
- BOOST_REQUIRE_THROW(storage->OpenForWrite(id), P2PVR::StorageException);
- storage->Delete(id);
+BOOST_AUTO_TEST_CASE( st_openWriteCloseNoMuxer )
+{
+ IceTray::OptionsResolver<StorageI::Options> opts;
+ const_cast<std::string &>(opts->muxerCommand).clear();
+ runTest(recordings, storage);
}
BOOST_AUTO_TEST_SUITE_END()