1
0
mirror of https://github.com/falk-werner/webfuse-provider synced 2024-10-27 20:44:10 +00:00
falk-werner_webfuse-provider/test/webfuse_provider/provider/operation/test_close.cc

86 lines
2.3 KiB
C++
Raw Normal View History

2020-06-16 21:39:45 +00:00
#include "webfuse_provider/impl/operation/close.h"
#include "webfuse_provider/impl/json/parser.h"
2020-06-16 21:39:45 +00:00
#include "webfuse_provider/mocks/mock_provider.hpp"
#include "webfuse_provider/mocks/fake_invokation_context.hpp"
2020-03-29 17:30:08 +00:00
#include <gtest/gtest.h>
using ::webfuse_test::MockProvider;
2020-03-30 18:40:03 +00:00
using ::webfuse_test::create_context;
2020-03-29 17:30:08 +00:00
using ::testing::_;
TEST(wfp_close, close)
{
MockProvider provider;
EXPECT_CALL(provider, close(42, 101, 23)).Times(1);
2020-03-29 17:30:08 +00:00
wfp_impl_invokation_context context = create_context(provider);
char params[] = "[\"test.filesystem\", 42, 101, 23]";
wfp_json_doc * doc = wfp_impl_json_parse(params);
2020-03-29 17:30:08 +00:00
wfp_impl_close(&context, wfp_impl_json_root(doc), 42);
wfp_impl_json_dispose(doc);
2020-03-29 17:30:08 +00:00
}
TEST(wfp_close, close_fail_invalid_param_count)
{
MockProvider provider;
EXPECT_CALL(provider, close(_,_,_)).Times(0);
wfp_impl_invokation_context context = create_context(provider);
char params[] = "[]";
wfp_json_doc * doc = wfp_impl_json_parse(params);
wfp_impl_close(&context, wfp_impl_json_root(doc), 42);
wfp_impl_json_dispose(doc);
2020-03-29 17:30:08 +00:00
}
TEST(wfp_close, close_fail_inode_invalid_type)
{
MockProvider provider;
EXPECT_CALL(provider, close(_,_,_)).Times(0);
wfp_impl_invokation_context context = create_context(provider);
char params[] = "[\"test.filesystem\", \"42\", 0, 0]";
wfp_json_doc * doc = wfp_impl_json_parse(params);
2020-03-29 17:30:08 +00:00
wfp_impl_close(&context, wfp_impl_json_root(doc), 42);
wfp_impl_json_dispose(doc);
2020-03-29 17:30:08 +00:00
}
TEST(wfp_close, close_fail_handle_invalid_type)
{
MockProvider provider;
EXPECT_CALL(provider, close(_,_,_)).Times(0);
wfp_impl_invokation_context context = create_context(provider);
char params[] = "[\"test.filesystem\", 0, \"42\", 0]";
wfp_json_doc * doc = wfp_impl_json_parse(params);
2020-03-29 17:30:08 +00:00
wfp_impl_close(&context, wfp_impl_json_root(doc), 42);
wfp_impl_json_dispose(doc);
2020-03-29 17:30:08 +00:00
}
TEST(wfp_close, close_fail_flags_invalid_type)
{
MockProvider provider;
EXPECT_CALL(provider, close(_,_,_)).Times(0);
wfp_impl_invokation_context context = create_context(provider);
char params[] = "[\"test.filesystem\", 0, 0, \"42\"]";
wfp_json_doc * doc = wfp_impl_json_parse(params);
2020-03-29 17:30:08 +00:00
wfp_impl_close(&context, wfp_impl_json_root(doc), 42);
wfp_impl_json_dispose(doc);
2020-03-29 17:30:08 +00:00
}
TEST(wfp_close, default_nop)
{
wfp_impl_close_default(0, 0, 0, nullptr);
}