Commit 31da5d03 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

FolderTests: Ensure it's safe to unban an unexisting/unbanned folder

parent 6a0530d0
......@@ -38,6 +38,7 @@ public:
: m_discoveryDone( false )
, m_reloadDone( false )
, m_banFolderDone( false )
, m_unbanFolderDone( false )
, m_entryPointRemoved( false )
{
}
......@@ -61,6 +62,12 @@ public:
m_cond.notify_all();
}
virtual void onEntryPointUnbanned( const std::string&, bool ) override
{
m_unbanFolderDone = true;
m_cond.notify_all();
}
virtual void onEntryPointRemoved( const std::string&, bool ) override
{
m_entryPointRemoved = true;
......@@ -97,6 +104,16 @@ public:
return res;
}
bool waitUnbanFolder()
{
std::unique_lock<compat::Mutex> lock( m_mutex );
auto res = m_cond.wait_for( lock, std::chrono::seconds( 5 ), [this]() {
return m_unbanFolderDone.load();
});
m_unbanFolderDone = false;
return res;
}
bool waitEntryPointRemoved()
{
std::unique_lock<compat::Mutex> lock( m_mutex );
......@@ -111,6 +128,7 @@ private:
std::atomic_bool m_discoveryDone;
std::atomic_bool m_reloadDone;
std::atomic_bool m_banFolderDone;
std::atomic_bool m_unbanFolderDone;
std::atomic_bool m_entryPointRemoved;
compat::ConditionVariable m_cond;
compat::Mutex m_mutex;
......
......@@ -331,6 +331,20 @@ TEST_F( FoldersNoDiscover, BlacklistNonExistant )
cbMock->waitBanFolder();
}
TEST_F( FoldersNoDiscover, UnbanNonExistant )
{
ml->unbanFolder( "foo/bar/otters" );
cbMock->waitUnbanFolder();
ml->unbanFolder( "/foo/bar/otters" );
cbMock->waitUnbanFolder();
// Ban with an existing base
ml->unbanFolder( mock::FileSystemFactory::Root + "grouik/" );
cbMock->waitUnbanFolder();
// Ban existing but unbanned folder
ml->unbanFolder( mock::FileSystemFactory::Root );
cbMock->waitUnbanFolder();
}
TEST_F( FoldersNoDiscover, NoMediaBeforeDiscovery )
{
auto newFolder = mock::FileSystemFactory::Root + "newfolder/";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment