mirror of
https://github.com/falk-werner/webfuse-provider
synced 2026-03-02 04:09:18 +00:00
chore: re-enabled unit tests
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include "webfuse_provider/mocks/mock_request.hpp"
|
||||
#include "webfuse_provider/mocks/mock_provider.hpp"
|
||||
#include "webfuse_provider/mocks/fake_invokation_context.hpp"
|
||||
#include "webfuse_provider/test_util/json_doc.hpp"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <cstdlib>
|
||||
@@ -10,6 +11,7 @@ using ::webfuse_test::MockProvider;
|
||||
using ::webfuse_test::MockRequest;
|
||||
using ::webfuse_test::StatMatcher;
|
||||
using ::webfuse_test::create_context;
|
||||
using ::webfuse_test::JsonDoc;
|
||||
using ::testing::_;
|
||||
using ::testing::Invoke;
|
||||
|
||||
@@ -18,7 +20,7 @@ namespace
|
||||
|
||||
void free_request(wfp_request * request, ino_t)
|
||||
{
|
||||
free(request);
|
||||
wfp_impl_request_dispose(request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -60,19 +62,14 @@ TEST(wfp_impl_getattr, respond_dir)
|
||||
|
||||
TEST(wfp_impl_getattr, invoke_provider)
|
||||
{
|
||||
ino_t inode = 23;
|
||||
MockProvider provider;
|
||||
EXPECT_CALL(provider,getattr(_, inode)).Times(1).WillOnce(Invoke(free_request));
|
||||
EXPECT_CALL(provider,getattr(_, 23)).Times(1).WillOnce(Invoke(free_request));
|
||||
|
||||
wfp_request request = {nullptr, nullptr, 0};
|
||||
wfp_impl_invokation_context context = create_context(provider, &request);
|
||||
|
||||
json_t * params = json_array();
|
||||
json_array_append_new(params, json_string("test.filesystem"));
|
||||
json_array_append_new(params, json_integer(inode));
|
||||
|
||||
wfp_impl_getattr(&context, params, 42);
|
||||
json_decref(params);
|
||||
JsonDoc doc("[\"test.filesystem\", 23]");
|
||||
wfp_impl_getattr(&context, doc.root(), 42);
|
||||
}
|
||||
|
||||
TEST(wfp_impl_getattr, fail_invalid_param_count)
|
||||
@@ -83,11 +80,8 @@ TEST(wfp_impl_getattr, fail_invalid_param_count)
|
||||
wfp_request request = {nullptr, nullptr, 0};
|
||||
wfp_impl_invokation_context context = create_context(provider, &request);
|
||||
|
||||
json_t * params = json_array();
|
||||
json_array_append_new(params, json_string("test.filesystem"));
|
||||
|
||||
wfp_impl_getattr(&context, params, 42);
|
||||
json_decref(params);
|
||||
JsonDoc doc("[\"test.filesystem\"]");
|
||||
wfp_impl_getattr(&context, doc.root(), 42);
|
||||
}
|
||||
|
||||
TEST(wfp_impl_getattr, fail_invalid_inode_type)
|
||||
@@ -98,10 +92,6 @@ TEST(wfp_impl_getattr, fail_invalid_inode_type)
|
||||
wfp_request request = {nullptr, nullptr, 0};
|
||||
wfp_impl_invokation_context context = create_context(provider, &request);
|
||||
|
||||
json_t * params = json_array();
|
||||
json_array_append_new(params, json_string("test.filesystem"));
|
||||
json_array_append_new(params, json_string("42"));
|
||||
|
||||
wfp_impl_getattr(&context, params, 42);
|
||||
json_decref(params);
|
||||
JsonDoc doc("[\"test.filesystem\", \"42\"]");
|
||||
wfp_impl_getattr(&context, doc.root(), 42);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "webfuse_provider/mocks/mock_request.hpp"
|
||||
#include "webfuse_provider/mocks/mock_provider.hpp"
|
||||
#include "webfuse_provider/mocks/fake_invokation_context.hpp"
|
||||
#include "webfuse_provider/test_util/json_doc.hpp"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <cstdlib>
|
||||
@@ -10,6 +11,7 @@ using ::webfuse_test::MockProvider;
|
||||
using ::webfuse_test::MockRequest;
|
||||
using ::webfuse_test::StatMatcher;
|
||||
using ::webfuse_test::create_context;
|
||||
using ::webfuse_test::JsonDoc;
|
||||
using ::testing::_;
|
||||
using ::testing::Invoke;
|
||||
using ::testing::StrEq;
|
||||
@@ -19,28 +21,22 @@ namespace
|
||||
|
||||
void free_request(wfp_request * request, ino_t, char const *)
|
||||
{
|
||||
free(request);
|
||||
wfp_impl_request_dispose(request);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TEST(wfp_impl_lookup, invoke_provider)
|
||||
{
|
||||
ino_t inode = 42;
|
||||
MockProvider provider;
|
||||
EXPECT_CALL(provider,lookup(_, inode,StrEq("some.file"))).Times(1)
|
||||
EXPECT_CALL(provider,lookup(_, 42,StrEq("some.file"))).Times(1)
|
||||
.WillOnce(Invoke(free_request));
|
||||
|
||||
wfp_request request = {nullptr, nullptr, 0};
|
||||
wfp_impl_invokation_context context = create_context(provider, &request);
|
||||
|
||||
json_t * params = json_array();
|
||||
json_array_append_new(params, json_string("test.filesystem"));
|
||||
json_array_append_new(params, json_integer(inode));
|
||||
json_array_append_new(params, json_string("some.file"));
|
||||
|
||||
wfp_impl_lookup(&context, params, 42);
|
||||
json_decref(params);
|
||||
JsonDoc doc("[\"test.filesystem\", 42, \"some.file\"]");
|
||||
wfp_impl_lookup(&context, doc.root(), 42);
|
||||
}
|
||||
|
||||
TEST(wfp_impl_lookup, fail_invalid_param_count)
|
||||
@@ -51,12 +47,8 @@ TEST(wfp_impl_lookup, fail_invalid_param_count)
|
||||
wfp_request request = {nullptr, nullptr, 0};
|
||||
wfp_impl_invokation_context context = create_context(provider, &request);
|
||||
|
||||
json_t * params = json_array();
|
||||
json_array_append_new(params, json_string("test.filesystem"));
|
||||
json_array_append_new(params, json_integer(23));
|
||||
|
||||
wfp_impl_lookup(&context, params, 42);
|
||||
json_decref(params);
|
||||
JsonDoc doc("[\"test.filesystem\", 23]");
|
||||
wfp_impl_lookup(&context, doc.root(), 42);
|
||||
}
|
||||
|
||||
TEST(wfp_impl_lookup, fail_invalid_inode_type)
|
||||
@@ -67,13 +59,8 @@ TEST(wfp_impl_lookup, fail_invalid_inode_type)
|
||||
wfp_request request = {nullptr, nullptr, 0};
|
||||
wfp_impl_invokation_context context = create_context(provider, &request);
|
||||
|
||||
json_t * params = json_array();
|
||||
json_array_append_new(params, json_string("test.filesystem"));
|
||||
json_array_append_new(params, json_string("23"));
|
||||
json_array_append_new(params, json_string("some.file"));
|
||||
|
||||
wfp_impl_lookup(&context, params, 42);
|
||||
json_decref(params);
|
||||
JsonDoc doc("[\"test.filesystem\", \"23\", \"some.file\"]");
|
||||
wfp_impl_lookup(&context, doc.root(), 42);
|
||||
}
|
||||
|
||||
TEST(wfp_impl_lookup, fail_invalid_name_type)
|
||||
@@ -84,13 +71,8 @@ TEST(wfp_impl_lookup, fail_invalid_name_type)
|
||||
wfp_request request = {nullptr, nullptr, 0};
|
||||
wfp_impl_invokation_context context = create_context(provider, &request);
|
||||
|
||||
json_t * params = json_array();
|
||||
json_array_append_new(params, json_string("test.filesystem"));
|
||||
json_array_append_new(params, json_integer(23));
|
||||
json_array_append_new(params, json_integer(1));
|
||||
|
||||
wfp_impl_lookup(&context, params, 42);
|
||||
json_decref(params);
|
||||
JsonDoc doc("[\"test.filesystem\", 23, 1]");
|
||||
wfp_impl_lookup(&context, doc.root(), 42);
|
||||
}
|
||||
|
||||
TEST(wfp_impl_lookup, default_responds_error)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "webfuse_provider/mocks/mock_request.hpp"
|
||||
#include "webfuse_provider/mocks/mock_provider.hpp"
|
||||
#include "webfuse_provider/mocks/fake_invokation_context.hpp"
|
||||
#include "webfuse_provider/test_util/json_doc.hpp"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <cstdlib>
|
||||
@@ -10,6 +11,7 @@ using ::webfuse_test::MockProvider;
|
||||
using ::webfuse_test::MockRequest;
|
||||
using ::webfuse_test::OpenMatcher;
|
||||
using ::webfuse_test::create_context;
|
||||
using ::webfuse_test::JsonDoc;
|
||||
using ::testing::_;
|
||||
using ::testing::Invoke;
|
||||
using ::testing::StrEq;
|
||||
@@ -19,29 +21,22 @@ namespace
|
||||
|
||||
void free_request(wfp_request * request, ino_t, int)
|
||||
{
|
||||
free(request);
|
||||
wfp_impl_request_dispose(request);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TEST(wfp_impl_open, invoke_provider)
|
||||
{
|
||||
ino_t inode = 42;
|
||||
int flags = 0;
|
||||
MockProvider provider;
|
||||
EXPECT_CALL(provider,open(_, inode, flags)).Times(1)
|
||||
EXPECT_CALL(provider,open(_, 42, 0)).Times(1)
|
||||
.WillOnce(Invoke(free_request));
|
||||
|
||||
wfp_request request = {nullptr, nullptr, 0};
|
||||
wfp_impl_invokation_context context = create_context(provider, &request);
|
||||
|
||||
json_t * params = json_array();
|
||||
json_array_append_new(params, json_string("test.filesystem"));
|
||||
json_array_append_new(params, json_integer(inode));
|
||||
json_array_append_new(params, json_integer(flags));
|
||||
|
||||
wfp_impl_open(&context, params, 42);
|
||||
json_decref(params);
|
||||
JsonDoc doc("[\"test.filesystem\",42,0]");
|
||||
wfp_impl_open(&context, doc.root(), 42);
|
||||
}
|
||||
|
||||
TEST(wfp_impl_open, fail_invalid_param_count)
|
||||
@@ -52,12 +47,8 @@ TEST(wfp_impl_open, fail_invalid_param_count)
|
||||
wfp_request request = {nullptr, nullptr, 0};
|
||||
wfp_impl_invokation_context context = create_context(provider, &request);
|
||||
|
||||
json_t * params = json_array();
|
||||
json_array_append_new(params, json_string("test.filesystem"));
|
||||
json_array_append_new(params, json_integer(23));
|
||||
|
||||
wfp_impl_open(&context, params, 42);
|
||||
json_decref(params);
|
||||
JsonDoc doc("[\"test.filesystem\", 23]");
|
||||
wfp_impl_open(&context, doc.root(), 42);
|
||||
}
|
||||
|
||||
TEST(wfp_impl_open, fail_invalid_inode_type)
|
||||
@@ -68,13 +59,8 @@ TEST(wfp_impl_open, fail_invalid_inode_type)
|
||||
wfp_request request = {nullptr, nullptr, 0};
|
||||
wfp_impl_invokation_context context = create_context(provider, &request);
|
||||
|
||||
json_t * params = json_array();
|
||||
json_array_append_new(params, json_string("test.filesystem"));
|
||||
json_array_append_new(params, json_string(""));
|
||||
json_array_append_new(params, json_integer(0));
|
||||
|
||||
wfp_impl_open(&context, params, 42);
|
||||
json_decref(params);
|
||||
JsonDoc doc("[\"test.filesystem\", \"\", 0]");
|
||||
wfp_impl_open(&context, doc.root(), 42);
|
||||
}
|
||||
|
||||
TEST(wfp_impl_open, fail_invalid_flags_type)
|
||||
@@ -85,13 +71,8 @@ TEST(wfp_impl_open, fail_invalid_flags_type)
|
||||
wfp_request request = {nullptr, nullptr, 0};
|
||||
wfp_impl_invokation_context context = create_context(provider, &request);
|
||||
|
||||
json_t * params = json_array();
|
||||
json_array_append_new(params, json_string("test.filesystem"));
|
||||
json_array_append_new(params, json_integer(23));
|
||||
json_array_append_new(params, json_string(""));
|
||||
|
||||
wfp_impl_open(&context, params, 42);
|
||||
json_decref(params);
|
||||
JsonDoc doc("[\"test.filesystem\", 23, \"\"]");
|
||||
wfp_impl_open(&context, doc.root(), 42);
|
||||
}
|
||||
|
||||
TEST(wfp_impl_open, default_responds_error)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "webfuse_provider/mocks/mock_request.hpp"
|
||||
#include "webfuse_provider/mocks/mock_provider.hpp"
|
||||
#include "webfuse_provider/mocks/fake_invokation_context.hpp"
|
||||
#include "webfuse_provider/test_util/json_doc.hpp"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <cstdlib>
|
||||
@@ -10,6 +11,7 @@ using ::webfuse_test::MockProvider;
|
||||
using ::webfuse_test::MockRequest;
|
||||
using ::webfuse_test::ReadResultMatcher;
|
||||
using ::webfuse_test::create_context;
|
||||
using ::webfuse_test::JsonDoc;
|
||||
using ::testing::_;
|
||||
using ::testing::Invoke;
|
||||
using ::testing::StrEq;
|
||||
@@ -19,33 +21,22 @@ namespace
|
||||
|
||||
void free_request(wfp_request * request, ino_t, uint32_t, size_t ,size_t)
|
||||
{
|
||||
free(request);
|
||||
wfp_impl_request_dispose(request);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TEST(wfp_impl_read, invoke_provider)
|
||||
{
|
||||
ino_t inode = 42;
|
||||
uint32_t handle = 5;
|
||||
size_t offset = 2;
|
||||
size_t length = 1;
|
||||
MockProvider provider;
|
||||
EXPECT_CALL(provider, read(_, inode, handle, offset, length)).Times(1)
|
||||
EXPECT_CALL(provider, read(_, 42, 5, 2, 1)).Times(1)
|
||||
.WillOnce(Invoke(free_request));
|
||||
|
||||
wfp_request request = {nullptr, nullptr, 0};
|
||||
wfp_impl_invokation_context context = create_context(provider, &request);
|
||||
|
||||
json_t * params = json_array();
|
||||
json_array_append_new(params, json_string("test.filesystem"));
|
||||
json_array_append_new(params, json_integer(inode));
|
||||
json_array_append_new(params, json_integer(handle));
|
||||
json_array_append_new(params, json_integer(offset));
|
||||
json_array_append_new(params, json_integer(length));
|
||||
|
||||
wfp_impl_read(&context, params, 42);
|
||||
json_decref(params);
|
||||
JsonDoc doc("[\"test.filesystem\",42,5,2,1]");
|
||||
wfp_impl_read(&context, doc.root(), 42);
|
||||
}
|
||||
|
||||
TEST(wfp_impl_read, fail_invalid_param_count)
|
||||
@@ -56,16 +47,8 @@ TEST(wfp_impl_read, fail_invalid_param_count)
|
||||
wfp_request request = {nullptr, nullptr, 0};
|
||||
wfp_impl_invokation_context context = create_context(provider, &request);
|
||||
|
||||
json_t * params = json_array();
|
||||
json_array_append_new(params, json_string("test.filesystem"));
|
||||
json_array_append_new(params, json_integer(1));
|
||||
json_array_append_new(params, json_integer(2));
|
||||
json_array_append_new(params, json_integer(3));
|
||||
json_array_append_new(params, json_integer(4));
|
||||
json_array_append_new(params, json_integer(5));
|
||||
|
||||
wfp_impl_read(&context, params, 42);
|
||||
json_decref(params);
|
||||
JsonDoc doc("[\"test.filesyste\",1,2,3,4,5]");
|
||||
wfp_impl_read(&context, doc.root(), 42);
|
||||
}
|
||||
|
||||
TEST(wfp_impl_read, fail_invalid_inode_type)
|
||||
@@ -76,15 +59,8 @@ TEST(wfp_impl_read, fail_invalid_inode_type)
|
||||
wfp_request request = {nullptr, nullptr, 0};
|
||||
wfp_impl_invokation_context context = create_context(provider, &request);
|
||||
|
||||
json_t * params = json_array();
|
||||
json_array_append_new(params, json_string("test.filesystem"));
|
||||
json_array_append_new(params, json_string("42"));
|
||||
json_array_append_new(params, json_integer(2));
|
||||
json_array_append_new(params, json_integer(3));
|
||||
json_array_append_new(params, json_integer(4));
|
||||
|
||||
wfp_impl_read(&context, params, 42);
|
||||
json_decref(params);
|
||||
JsonDoc doc("[\"test.filesyste\",\"42\",2,3,4]");
|
||||
wfp_impl_read(&context, doc.root(), 42);
|
||||
}
|
||||
|
||||
TEST(wfp_impl_read, fail_invalid_handle_type)
|
||||
@@ -95,15 +71,8 @@ TEST(wfp_impl_read, fail_invalid_handle_type)
|
||||
wfp_request request = {nullptr, nullptr, 0};
|
||||
wfp_impl_invokation_context context = create_context(provider, &request);
|
||||
|
||||
json_t * params = json_array();
|
||||
json_array_append_new(params, json_string("test.filesystem"));
|
||||
json_array_append_new(params, json_integer(1));
|
||||
json_array_append_new(params, json_string("42"));
|
||||
json_array_append_new(params, json_integer(3));
|
||||
json_array_append_new(params, json_integer(4));
|
||||
|
||||
wfp_impl_read(&context, params, 42);
|
||||
json_decref(params);
|
||||
JsonDoc doc("[\"test.filesyste\",1,\"42\",3,4]");
|
||||
wfp_impl_read(&context, doc.root(), 42);
|
||||
}
|
||||
|
||||
TEST(wfp_impl_read, fail_invalid_offset_type)
|
||||
@@ -114,15 +83,8 @@ TEST(wfp_impl_read, fail_invalid_offset_type)
|
||||
wfp_request request = {nullptr, nullptr, 0};
|
||||
wfp_impl_invokation_context context = create_context(provider, &request);
|
||||
|
||||
json_t * params = json_array();
|
||||
json_array_append_new(params, json_string("test.filesystem"));
|
||||
json_array_append_new(params, json_integer(1));
|
||||
json_array_append_new(params, json_integer(2));
|
||||
json_array_append_new(params, json_string("42"));
|
||||
json_array_append_new(params, json_integer(4));
|
||||
|
||||
wfp_impl_read(&context, params, 42);
|
||||
json_decref(params);
|
||||
JsonDoc doc("[\"test.filesyste\",1,2,\"42\",4]");
|
||||
wfp_impl_read(&context, doc.root(), 42);
|
||||
}
|
||||
|
||||
TEST(wfp_impl_read, fail_invalid_length_type)
|
||||
@@ -133,15 +95,8 @@ TEST(wfp_impl_read, fail_invalid_length_type)
|
||||
wfp_request request = {nullptr, nullptr, 0};
|
||||
wfp_impl_invokation_context context = create_context(provider, &request);
|
||||
|
||||
json_t * params = json_array();
|
||||
json_array_append_new(params, json_string("test.filesystem"));
|
||||
json_array_append_new(params, json_integer(1));
|
||||
json_array_append_new(params, json_integer(2));
|
||||
json_array_append_new(params, json_integer(3));
|
||||
json_array_append_new(params, json_string("42"));
|
||||
|
||||
wfp_impl_read(&context, params, 42);
|
||||
json_decref(params);
|
||||
JsonDoc doc("[\"test.filesyste\",1,2,3,\"42\"]");
|
||||
wfp_impl_read(&context, doc.root(), 42);
|
||||
}
|
||||
|
||||
TEST(wfp_impl_read, default_responds_error)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "webfuse_provider/mocks/mock_provider.hpp"
|
||||
#include "webfuse_provider/mocks/fake_invokation_context.hpp"
|
||||
#include "webfuse_provider/dirbuffer.h"
|
||||
#include "webfuse_provider/test_util/json_doc.hpp"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <cstdlib>
|
||||
@@ -11,6 +12,7 @@ using ::webfuse_test::MockProvider;
|
||||
using ::webfuse_test::MockRequest;
|
||||
using ::webfuse_test::ReaddirMatcher;
|
||||
using ::webfuse_test::create_context;
|
||||
using ::webfuse_test::JsonDoc;
|
||||
using ::testing::_;
|
||||
using ::testing::Invoke;
|
||||
|
||||
@@ -19,26 +21,21 @@ namespace
|
||||
|
||||
void free_request(wfp_request * request, ino_t)
|
||||
{
|
||||
free(request);
|
||||
wfp_impl_request_dispose(request);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TEST(wfp_impl_readdir, invoke_provider)
|
||||
{
|
||||
ino_t inode = 23;
|
||||
MockProvider provider;
|
||||
EXPECT_CALL(provider,readdir(_, inode)).Times(1).WillOnce(Invoke(free_request));
|
||||
EXPECT_CALL(provider,readdir(_, 23)).Times(1).WillOnce(Invoke(free_request));
|
||||
|
||||
wfp_request request = {nullptr, nullptr, 0};
|
||||
wfp_impl_invokation_context context = create_context(provider, &request);
|
||||
|
||||
json_t * params = json_array();
|
||||
json_array_append_new(params, json_string("test.filesystem"));
|
||||
json_array_append_new(params, json_integer(inode));
|
||||
|
||||
wfp_impl_readdir(&context, params, 42);
|
||||
json_decref(params);
|
||||
JsonDoc doc("[\"test.filesystem\",23]");
|
||||
wfp_impl_readdir(&context, doc.root(), 42);
|
||||
}
|
||||
|
||||
TEST(wfp_impl_readdir, fail_invalid_param_count)
|
||||
@@ -49,13 +46,8 @@ TEST(wfp_impl_readdir, fail_invalid_param_count)
|
||||
wfp_request request = {nullptr, nullptr, 0};
|
||||
wfp_impl_invokation_context context = create_context(provider, &request);
|
||||
|
||||
json_t * params = json_array();
|
||||
json_array_append_new(params, json_string("test.filesystem"));
|
||||
json_array_append_new(params, json_integer(1));
|
||||
json_array_append_new(params, json_integer(1));
|
||||
|
||||
wfp_impl_readdir(&context, params, 42);
|
||||
json_decref(params);
|
||||
JsonDoc doc("[\"test.filesystem\",1,1]");
|
||||
wfp_impl_readdir(&context, doc.root(), 42);
|
||||
}
|
||||
|
||||
TEST(wfp_impl_readdir, fail_invalid_inode_type)
|
||||
@@ -66,12 +58,8 @@ TEST(wfp_impl_readdir, fail_invalid_inode_type)
|
||||
wfp_request request = {nullptr, nullptr, 0};
|
||||
wfp_impl_invokation_context context = create_context(provider, &request);
|
||||
|
||||
json_t * params = json_array();
|
||||
json_array_append_new(params, json_string("test.filesystem"));
|
||||
json_array_append_new(params, json_string("1"));
|
||||
|
||||
wfp_impl_readdir(&context, params, 42);
|
||||
json_decref(params);
|
||||
JsonDoc doc("[\"test.filesystem\",\"1\"]");
|
||||
wfp_impl_readdir(&context, doc.root(), 42);
|
||||
}
|
||||
|
||||
TEST(wfp_impl_readdir, default_responds_error)
|
||||
|
||||
Reference in New Issue
Block a user