Loading...
Searching...
No Matches
mock_storage.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#pragma once
21
23#include "gmock/gmock.h"
24
25namespace resdb {
26
27class MockStorage : public Storage {
28 public:
29 MOCK_METHOD(int, SetValue, (const std::string& key, const std::string& value),
30 (override));
31 MOCK_METHOD(std::string, GetValue, (const std::string& key), (override));
32 MOCK_METHOD(std::string, GetAllValues, (), (override));
33 MOCK_METHOD(std::string, GetRange, (const std::string&, const std::string&),
34 (override));
35
37 (const std::string& key, const std::string& value, int version),
38 (override));
39
40 using ValueType = std::pair<std::string, int>;
41 using ItemsType = std::map<std::string, ValueType>;
42 using ValuesType = std::vector<ValueType>;
43
45 (const std::string& key, int version), (override));
47 MOCK_METHOD(ItemsType, GetKeyRange, (const std::string&, const std::string&),
48 (override));
49 MOCK_METHOD(ValuesType, GetHistory, (const std::string&, int, int),
50 (override));
51 MOCK_METHOD(ValuesType, GetTopHistory, (const std::string&, int), (override));
52
53 MOCK_METHOD(bool, Flush, (), (override));
54};
55
56} // namespace resdb
MOCK_METHOD(std::string, GetAllValues,(),(override))
MOCK_METHOD(bool, Flush,(),(override))
std::pair< std::string, int > ValueType
std::vector< ValueType > ValuesType
MOCK_METHOD(std::string, GetRange,(const std::string &, const std::string &),(override))
MOCK_METHOD(int, SetValueWithVersion,(const std::string &key, const std::string &value, int version),(override))
MOCK_METHOD(int, SetValue,(const std::string &key, const std::string &value),(override))
MOCK_METHOD(ValuesType, GetTopHistory,(const std::string &, int),(override))
MOCK_METHOD(ValueType, GetValueWithVersion,(const std::string &key, int version),(override))
std::map< std::string, ValueType > ItemsType
MOCK_METHOD(ValuesType, GetHistory,(const std::string &, int, int),(override))
MOCK_METHOD(std::string, GetValue,(const std::string &key),(override))
MOCK_METHOD(ItemsType, GetKeyRange,(const std::string &, const std::string &),(override))
MOCK_METHOD(ItemsType, GetAllItems,(),(override))
virtual std::vector< std::pair< std::string, int > > GetTopHistory(const std::string &key, int number)=0
virtual std::vector< std::pair< std::string, int > > GetHistory(const std::string &key, int min_version, int max_version)=0
virtual int SetValueWithVersion(const std::string &key, const std::string &value, int version)=0
virtual int SetValue(const std::string &key, const std::string &value)=0
virtual bool Flush()
Definition storage.h:57
virtual std::string GetRange(const std::string &min_key, const std::string &max_key)=0
virtual std::string GetAllValues()=0
virtual std::string GetValue(const std::string &key)=0
virtual std::map< std::string, std::pair< std::string, int > > GetAllItems()=0
virtual std::map< std::string, std::pair< std::string, int > > GetKeyRange(const std::string &min_key, const std::string &max_key)=0
virtual std::pair< std::string, int > GetValueWithVersion(const std::string &key, int version)=0