Skip to content

Commit

Permalink
add comments to mock classes
Browse files Browse the repository at this point in the history
Signed-off-by: eric846 <[email protected]>
  • Loading branch information
eric846 committed Sep 14, 2020
1 parent 80578fa commit 50bc113
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/mocks/adaptive_load/mock_metrics_evaluator.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,22 @@

namespace Nighthawk {

/**
* A mock MetricsEvaluator that returns empty values from all methods.
*
* Typical usage:
*
* MockMetricsEvaluator mock_metrics_evaluator;
* BenchmarkResult benchmark_result;
* // (set benchmark_result fields here)
* EXPECT_CALL(mock_metrics_evaluator, AnalyzeNighthawkBenchmark(_, _, _))
* .WillRepeatedly(Return(benchmark_result));
*/
class MockMetricsEvaluator : public MetricsEvaluator {
public:
/**
* Empty constructor.
*/
MockMetricsEvaluator();

MOCK_CONST_METHOD3(EvaluateMetric,
Expand Down
22 changes: 22 additions & 0 deletions test/mocks/adaptive_load/mock_session_spec_proto_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,30 @@

namespace Nighthawk {

/**
* A mock AdaptiveLoadSessionSpecProtoHelper that returns empty values or success from all methods
* by default.
*
* In particular, SetSessionSpecDefaults does not pass its input value through to its output;
* regardless of the output, it returns an empty proto, unless explicitly configured (see below). If
* you don't need to inspect calls to the spec proto helper, it may be easier to use the real
* AdaptiveLoadSessionSpecProtoHelperImpl in tests instead.
*
* Typical usage:
*
* NiceMock<MockAdaptiveLoadSessionSpecProtoHelper> mock_spec_proto_helper;
* EXPECT_CALL(mock_spec_proto_helper, CheckSessionSpec(_))
* .WillOnce(Return(absl::OkStatus()));
* AdaptiveLoadSessionSpec spec;
* // Set spec fields here, including providing all defaults yourself.
* EXPECT_CALL(mock_spec_proto_helper, SetSessionSpecDefaults(_))
* .WillOnce(Return(spec));
*/
class MockAdaptiveLoadSessionSpecProtoHelper : public AdaptiveLoadSessionSpecProtoHelper {
public:
/**
* Empty constructor.
*/
MockAdaptiveLoadSessionSpecProtoHelper();

MOCK_CONST_METHOD1(SetSessionSpecDefaults,
Expand Down
13 changes: 13 additions & 0 deletions test/mocks/common/mock_nighthawk_service_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,21 @@

namespace Nighthawk {

/**
* A mock NighthawkServiceClient that returns an empty response by default.
*
* Typical usage:
*
* NiceMock<MockNighthawkServiceClient> mock_nighthawk_service_client;
* nighthawk::client::ExecutionResponse nighthawk_response;
* EXPECT_CALL(mock_nighthawk_service_client, PerformNighthawkBenchmark(_, _))
* .WillRepeatedly(Return(nighthawk_response));
*/
class MockNighthawkServiceClient : public NighthawkServiceClient {
public:
/**
* Empty constructor.
*/
MockNighthawkServiceClient();

MOCK_CONST_METHOD2(PerformNighthawkBenchmark,
Expand Down

0 comments on commit 50bc113

Please sign in to comment.