Skip to content

Commit 4a9adfe

Browse files
committed
Use hours instead of huge seconds in test code
1 parent d0a130b commit 4a9adfe

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

test/controller/PricePlanComparatorControllerTest.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <gmock/gmock.h>
2-
#include <rest/controller/PricePlanComparatorController.h>
32
#include <rest/configuration.h>
3+
#include <rest/controller/PricePlanComparatorController.h>
4+
45
#include <string>
56

67
#include <boost/beast/http.hpp>
@@ -20,10 +21,8 @@ class PricePlanComparatorControllerTest : public ::testing::Test {
2021

2122
TEST_F(PricePlanComparatorControllerTest, CompareShouldCalculateCostForMeterReadingsForEveryPricePlan) {
2223
const std::string smart_meter_id = "smart-meter-0";
23-
std::vector<ElectricityReading> readings = {
24-
{std::chrono::system_clock::now() - std::chrono::seconds(3600), 15 * 10000},
25-
{std::chrono::system_clock::now(), 5 * 10000}
26-
};
24+
std::vector<ElectricityReading> readings = {{std::chrono::system_clock::now() - std::chrono::hours{1}, 15 * 10000},
25+
{std::chrono::system_clock::now(), 5 * 10000}};
2726
meterReadingService.storeReadings(smart_meter_id, readings);
2827
http::request<http::string_body> req;
2928
std::vector<std::string> queries = {smart_meter_id};
@@ -78,10 +77,8 @@ TEST_F(PricePlanComparatorControllerTest, RecommandShouldRecommendLimitedCheapes
7877

7978
TEST_F(PricePlanComparatorControllerTest, RecommandShouldRecommendCheapestPricePlansMoreThanLimitAvailableForMeterUsage) {
8079
const std::string smart_meter_id = "smart-meter-0";
81-
std::vector<ElectricityReading> readings = {
82-
{std::chrono::system_clock::now() - std::chrono::seconds(3600), 25 * 10000},
83-
{std::chrono::system_clock::now(), 3 * 10000}
84-
};
80+
std::vector<ElectricityReading> readings = {{std::chrono::system_clock::now() - std::chrono::hours(1), 25 * 10000},
81+
{std::chrono::system_clock::now(), 3 * 10000}};
8582
meterReadingService.storeReadings(smart_meter_id, readings);
8683
http::request<http::string_body> req;
8784
std::vector<std::string> queries = {smart_meter_id, "limit", "5"};

0 commit comments

Comments
 (0)