xref: /aosp_15_r20/external/federated-compute/fcp/client/cache/test_helpers.h (revision 14675a029014e728ec732f129a32e299b2da0601)
1 // Copyright 2022 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef FCP_CLIENT_CACHE_TEST_HELPERS_H_
16 #define FCP_CLIENT_CACHE_TEST_HELPERS_H_
17 
18 #include "gmock/gmock.h"
19 #include "gtest/gtest.h"
20 #include "fcp/client/cache/resource_cache.h"
21 
22 namespace fcp {
23 namespace client {
24 namespace cache {
25 
26 // A mock `ResourceCache` implementation that can be used in tests.
27 class MockResourceCache : public ResourceCache {
28  public:
29   MOCK_METHOD(absl::Status, Put,
30               (absl::string_view cache_id, const absl::Cord& resource,
31                const google::protobuf::Any& metadata, absl::Duration max_age),
32               (override));
33   MOCK_METHOD(absl::StatusOr<ResourceAndMetadata>, Get,
34               (absl::string_view cache_id,
35                std::optional<absl::Duration> max_age),
36               (override));
37 };
38 
39 }  // namespace cache
40 }  // namespace client
41 }  // namespace fcp
42 
43 #endif  // FCP_CLIENT_CACHE_TEST_HELPERS_H_q
44