1
0
mirror of https://github.com/falk-werner/webfuse-provider synced 2024-09-30 04:20:46 +00:00
falk-werner_webfuse-provider/test/adapter/test_uuid_mountpoint_factory.cc

61 lines
2.0 KiB
C++
Raw Normal View History

#include <gtest/gtest.h>
#include "webfuse_adapter.h"
#include "webfuse/adapter/impl/uuid_mountpoint_factory.h"
#include "tempdir.hpp"
#include "file_utils.hpp"
using webfuse_test::TempDir;
using webfuse_test::is_dir;
TEST(uuid_mountpoint_factory, create_existing_dir)
{
TempDir temp("uuid_mountpoint_factory");
2020-02-16 20:03:17 +00:00
struct wf_impl_mountpoint_factory factory;
bool factory_created = wf_impl_uuid_mountpoint_factory_init(&factory, temp.path());
ASSERT_TRUE(factory_created);
ASSERT_TRUE(is_dir(temp.path()));
2020-02-16 20:03:17 +00:00
wf_mountpoint * mountpoint = wf_impl_mountpoint_factory_create_mountpoint(&factory, "dummy");
std::string path = wf_mountpoint_get_path(mountpoint);
ASSERT_TRUE(is_dir(path));
wf_mountpoint_dispose(mountpoint);
ASSERT_FALSE(is_dir(path));
2020-02-16 20:03:17 +00:00
wf_impl_mountpoint_factory_cleanup(&factory);
// keep dir not created by factory
ASSERT_TRUE(is_dir(temp.path()));
}
TEST(uuid_mountpoint_factory, create_nonexisting_dir)
{
TempDir temp("uuid_mountpoint_factory");
std::string root_path = std::string(temp.path()) + "/root";
2020-02-16 20:03:17 +00:00
struct wf_impl_mountpoint_factory factory;
bool factory_created = wf_impl_uuid_mountpoint_factory_init(&factory, root_path.c_str());
ASSERT_TRUE(factory_created);
ASSERT_TRUE(is_dir(root_path));
2020-02-16 20:03:17 +00:00
wf_mountpoint * mountpoint = wf_impl_mountpoint_factory_create_mountpoint(&factory, "dummy");
std::string path = wf_mountpoint_get_path(mountpoint);
ASSERT_TRUE(is_dir(path));
wf_mountpoint_dispose(mountpoint);
ASSERT_FALSE(is_dir(path));
2020-02-16 20:03:17 +00:00
wf_impl_mountpoint_factory_cleanup(&factory);
// remove dir, created by factory
ASSERT_FALSE(is_dir(root_path));
}
TEST(uuid_mountpoint_factory, fail_to_created_nested_dir)
{
TempDir temp("uuid_mountpoint_factory");
std::string root_path = std::string(temp.path()) + "/nested/root";
2020-02-16 20:03:17 +00:00
struct wf_impl_mountpoint_factory factory;
bool factory_created = wf_impl_uuid_mountpoint_factory_init(&factory, root_path.c_str());
ASSERT_FALSE(factory_created);
}