Commit 3f5d3144 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

tests: fs mock: Raise an assertion when a folder/file can't be found

This matches the unix fs actual implementation
parent 30dccc88
......@@ -165,7 +165,7 @@ struct FileSystemFactory : public fs::IFileSystemFactory
{
auto d = device( mrl );
if ( d == nullptr )
return std::make_shared<Directory>( "", nullptr );
throw std::system_error{ ENOENT, std::generic_category(), "Mock directory" };
auto dir = d->directory( mrl );
if ( dir == nullptr )
throw std::system_error{ ENOENT, std::generic_category(), "Mock directory" };
......
......@@ -25,6 +25,7 @@
#endif
#include <cassert>
#include <system_error>
#include "MockDevice.h"
#include "MockDirectory.h"
......@@ -106,7 +107,7 @@ std::shared_ptr<File> Device::file(const std::string& filePath )
std::shared_ptr<Directory> Device::directory(const std::string& path)
{
if ( m_root == nullptr || m_present == false )
return std::make_shared<Directory>( "", nullptr );
throw std::system_error{ ENOENT, std::generic_category(), "Mock directory" };
const auto relPath = relativePath( path );
if ( relPath.empty() == true )
return m_root;
......
......@@ -152,7 +152,7 @@ std::shared_ptr<Directory> Directory::directory(const std::string& path)
{
auto it = m_dirs.find( subFolder );
if ( it == end( m_dirs ) )
return std::make_shared<Directory>( "", nullptr );
throw std::system_error{ ENOENT, std::generic_category(), "Mock directory" };
return it->second;
}
else
......
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