forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mocks.h
86 lines (72 loc) · 3.07 KB
/
mocks.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#pragma once
#include <cstdint>
#include <string>
#include "envoy/runtime/runtime.h"
#include "envoy/type/v3/percent.pb.h"
#include "envoy/upstream/cluster_manager.h"
#include "test/mocks/stats/mocks.h"
#include "absl/container/node_hash_map.h"
#include "gmock/gmock.h"
namespace Envoy {
namespace Runtime {
class MockSnapshot : public Snapshot {
public:
MockSnapshot();
~MockSnapshot() override;
// Provide a default implementation of mocked featureEnabled/2.
bool featureEnabledDefault(absl::string_view, uint64_t default_value) {
if (default_value == 0) {
return false;
} else if (default_value == 100) {
return true;
} else {
throw std::invalid_argument("Not implemented yet. You may want to set expectation of mocked "
"featureEnabled() instead.");
}
}
MOCK_METHOD(bool, deprecatedFeatureEnabled, (absl::string_view key, bool default_enabled),
(const));
MOCK_METHOD(bool, runtimeFeatureEnabled, (absl::string_view key), (const));
MOCK_METHOD(bool, featureEnabled, (absl::string_view key, uint64_t default_value), (const));
MOCK_METHOD(bool, featureEnabled,
(absl::string_view key, uint64_t default_value, uint64_t random_value), (const));
MOCK_METHOD(bool, featureEnabled,
(absl::string_view key, uint64_t default_value, uint64_t random_value,
uint64_t num_buckets),
(const));
MOCK_METHOD(bool, featureEnabled,
(absl::string_view key, const envoy::type::v3::FractionalPercent& default_value),
(const));
MOCK_METHOD(bool, featureEnabled,
(absl::string_view key, const envoy::type::v3::FractionalPercent& default_value,
uint64_t random_value),
(const));
MOCK_METHOD(ConstStringOptRef, get, (absl::string_view key), (const));
MOCK_METHOD(uint64_t, getInteger, (absl::string_view key, uint64_t default_value), (const));
MOCK_METHOD(double, getDouble, (absl::string_view key, double default_value), (const));
MOCK_METHOD(bool, getBoolean, (absl::string_view key, bool default_value), (const));
MOCK_METHOD(const std::vector<OverrideLayerConstPtr>&, getLayers, (), (const));
};
class MockLoader : public Loader {
public:
MockLoader();
~MockLoader() override;
MOCK_METHOD(void, initialize, (Upstream::ClusterManager & cm));
MOCK_METHOD(const Snapshot&, snapshot, ());
MOCK_METHOD(SnapshotConstSharedPtr, threadsafeSnapshot, ());
MOCK_METHOD(void, mergeValues, ((const absl::node_hash_map<std::string, std::string>&)));
MOCK_METHOD(void, startRtdsSubscriptions, (ReadyCallback));
MOCK_METHOD(Stats::Scope&, getRootScope, ());
MOCK_METHOD(void, countDeprecatedFeatureUse, (), (const));
testing::NiceMock<MockSnapshot> snapshot_;
testing::NiceMock<Stats::MockStore> store_;
};
class MockOverrideLayer : public Snapshot::OverrideLayer {
public:
MockOverrideLayer();
~MockOverrideLayer() override;
MOCK_METHOD(const std::string&, name, (), (const));
MOCK_METHOD(const Snapshot::EntryMap&, values, (), (const));
};
} // namespace Runtime
} // namespace Envoy