| 65 | }; |
| 66 | |
| 67 | TEST(ResourceList, refresh) |
| 68 | { |
| 69 | auto handler = std::make_shared<MockHttpHandler>(); |
| 70 | HueCommandAPI commands(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler); |
| 71 | |
| 72 | const std::string path = "/resources"; |
| 73 | { |
| 74 | ResourceList<TestResource, int> list(commands, path, std::chrono::steady_clock::duration::max()); |
| 75 | EXPECT_CALL(*handler, |
| 76 | GETJson("/api/" + getBridgeUsername() + path, nlohmann::json::object(), getBridgeIp(), getBridgePort())) |
| 77 | .Times(2) |
| 78 | .WillRepeatedly(Return(nlohmann::json::object())); |
| 79 | list.refresh(); |
| 80 | list.refresh(); |
| 81 | Mock::VerifyAndClearExpectations(handler.get()); |
| 82 | } |
| 83 | { |
| 84 | auto baseCache = std::make_shared<APICache>("", commands, std::chrono::steady_clock::duration::max(), nullptr); |
| 85 | ResourceList<TestResource, int> list(baseCache, "resources", std::chrono::steady_clock::duration::max()); |
| 86 | InSequence s; |
| 87 | EXPECT_CALL( |
| 88 | *handler, GETJson("/api/" + getBridgeUsername(), nlohmann::json::object(), getBridgeIp(), getBridgePort())) |
| 89 | .WillOnce(Return(nlohmann::json {{"resources", nlohmann::json::object()}})); |
| 90 | EXPECT_CALL(*handler, |
| 91 | GETJson("/api/" + getBridgeUsername() + path, nlohmann::json::object(), getBridgeIp(), getBridgePort())) |
| 92 | .Times(2) |
| 93 | .WillRepeatedly(Return(nlohmann::json::object())); |
| 94 | list.refresh(); |
| 95 | list.refresh(); |
| 96 | list.refresh(); |
| 97 | Mock::VerifyAndClearExpectations(handler.get()); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | TEST(ResourceList, get) |
| 102 | { |
nothing calls this directly
no test coverage detected