mirror of
https://github.com/falk-werner/webfuse-provider
synced 2024-10-27 20:44:10 +00:00
added test for open
This commit is contained in:
parent
3ca4d89fa7
commit
47537e2ea6
@ -119,7 +119,6 @@ TEST(Client, ConnectFailNotReachable)
|
||||
wfp_client_config_dispose(config);
|
||||
}
|
||||
|
||||
|
||||
TEST(Client, Lookup)
|
||||
{
|
||||
MockProviderClient provider;
|
||||
@ -223,10 +222,9 @@ TEST(Client, Open)
|
||||
EXPECT_CALL(provider, OnDisconnected()).Times(1)
|
||||
.WillOnce(Invoke([&]() { disconnected.set_value(); }));
|
||||
|
||||
EXPECT_CALL(provider, Lookup(1,StrEq("foo"),_)).Times(1)
|
||||
.WillOnce(Invoke([](ino_t, char const *, struct stat * result) {
|
||||
result->st_ino = 42;
|
||||
result->st_mode = S_IFREG | 0644;
|
||||
EXPECT_CALL(provider, Open(1, 0, _)).Times(1)
|
||||
.WillOnce(Invoke([](int, int, uint32_t * handle) {
|
||||
*handle = 4711;
|
||||
}));
|
||||
|
||||
wfp_client_config * config = wfp_client_config_create();
|
||||
@ -238,18 +236,12 @@ TEST(Client, Open)
|
||||
|
||||
ASSERT_EQ(std::future_status::ready, connected.get_future().wait_for(TIMEOUT));
|
||||
|
||||
json_t * response = server.Lookup(1, "foo");
|
||||
json_t * response = server.Open(1, 0);
|
||||
ASSERT_TRUE(json_is_object(response));
|
||||
json_t * result = json_object_get(response, "result");
|
||||
|
||||
json_t * inode = json_object_get(result, "inode");
|
||||
ASSERT_EQ(42, json_integer_value(inode));
|
||||
|
||||
json_t * mode = json_object_get(result, "mode");
|
||||
ASSERT_EQ(0644, json_integer_value(mode));
|
||||
|
||||
json_t * type = json_object_get(result, "type");
|
||||
ASSERT_STREQ("file", json_string_value(type));
|
||||
json_t * handle = json_object_get(result, "handle");
|
||||
ASSERT_EQ(4711, json_integer_value(handle));
|
||||
|
||||
json_decref(response);
|
||||
|
||||
|
@ -328,5 +328,15 @@ json_t * WebfuseServer::Lookup(int parent, std::string const & name)
|
||||
return d->Invoke("lookup", params);
|
||||
}
|
||||
|
||||
json_t * WebfuseServer::Open(int inode, int flags)
|
||||
{
|
||||
json_t * params = json_array();
|
||||
json_array_append_new(params, json_string(d->GetFilesystem().c_str()));
|
||||
json_array_append_new(params, json_integer(inode));
|
||||
json_array_append_new(params, json_integer(flags));
|
||||
|
||||
return d->Invoke("open", params);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -18,6 +18,7 @@ public:
|
||||
json_t * Invoke(std::string const & method, json_t * params);
|
||||
json_t * Invoke(std::string const & method, std::string const & params);
|
||||
json_t * Lookup(int parent, std::string const & name);
|
||||
json_t * Open(int inode, int flags);
|
||||
private:
|
||||
class Private;
|
||||
Private * d;
|
||||
|
Loading…
Reference in New Issue
Block a user