ipfs-chromium
Loading...
Searching...
No Matches
mock_requestor.h
1#ifndef IPFS_TEST_REQUESTOR_H_
2#define IPFS_TEST_REQUESTOR_H_
3
4#include <ipfs_client/client.h>
5#include <ipfs_client/gw/requestor.h>
6
7#include <gtest/gtest.h>
8
9namespace i = ipfs;
10namespace ig = i::gw;
11
12namespace {
13struct MockRequestor final : public ig::Requestor {
14 using RequestPtr = ig::RequestPtr;
15 using ContextApi = i::Client;
16 using O = MockRequestor::HandleOutcome;
17 std::vector<RequestPtr> requests;
18 std::vector<HandleOutcome> outcomes;
19 HandleOutcome handle(RequestPtr p) {
20 requests.push_back(p);
21 auto result = outcomes.at(0);
22 outcomes.erase(outcomes.begin());
23 return result;
24 }
25 std::string name_ = "MockRequestor";
26 std::string_view name() const { return name_; }
27 std::shared_ptr<ContextApi> api() const { return api_; }
28 void api(std::shared_ptr<ContextApi> a) { api_ = a; }
29};
30} // namespace
31
32#endif // IPFS_TEST_REQUESTOR_H_
Interface that provides functionality from whatever environment you're using this library in.
Definition client.h:42