1
0
mirror of https://github.com/falk-werner/webfuse-provider synced 2026-03-02 04:09:18 +00:00

added ondispose to mountpoint to allow custom cleanup

This commit is contained in:
Falk Werner
2020-02-15 15:50:32 +01:00
parent e727a9a54d
commit 6a94cea6f9
5 changed files with 76 additions and 1 deletions

View File

@@ -1,12 +1,45 @@
#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include "webfuse/adapter/mountpoint.h"
namespace
{
class MockMountpointDisposer
{
public:
MOCK_METHOD1(ondispose, void(wf_mountpoint * mountpoint));
};
MockMountpointDisposer * global_disposer = nullptr;
void ondispose(wf_mountpoint * mountpoint)
{
global_disposer->ondispose(mountpoint);
}
}
TEST(mountpoint, get_path)
{
wf_mountpoint * mountpoint = wf_mountpoint_create("/some/path");
ASSERT_NE(nullptr, mountpoint);
ASSERT_STREQ("/some/path", wf_mountpoint_get_path(mountpoint));
wf_mountpoint_dispose(mountpoint);
}
TEST(mountpoint, ondispose)
{
MockMountpointDisposer disposer;
global_disposer = &disposer;
wf_mountpoint * mountpoint = wf_mountpoint_create("/some/path");
ASSERT_NE(nullptr, mountpoint);
wf_mountpoint_set_ondispose(mountpoint, ondispose);
EXPECT_CALL(disposer, ondispose(mountpoint)).Times(1);
wf_mountpoint_dispose(mountpoint);
}