Skip to content

Commit a8def22

Browse files
author
Liubov Didkivska
authored
Init get version response. (#1081)
In case if we do not request version online CatalogVersionResponse variable stays initialized bu default with error code unknown. If getting from cache also fails we do not exchange result, so it should be NotFound. Relates-To: OLPEDGE-2339 Signed-off-by: Liubov Didkivska <[email protected]>
1 parent ce30ce6 commit a8def22

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

codecov.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,5 @@ ignore:
4444
- examples
4545
- docs
4646
- external
47+
- build
4748

olp-cpp-sdk-dataservice-read/src/repositories/CatalogRepository.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,10 @@ CatalogVersionResponse CatalogRepository::GetLatestVersion(
110110
repository::CatalogCacheRepository repository(catalog_, settings_.cache);
111111

112112
const auto fetch_option = request.GetFetchOption();
113-
114-
CatalogVersionResponse version_response;
113+
// in case if get version online was never called and version was not found in
114+
// cache
115+
CatalogVersionResponse version_response = {
116+
{client::ErrorCode::NotFound, "Failed to find version."}};
115117

116118
if (fetch_option != CacheOnly) {
117119
version_response = GetLatestVersionOnline(request.GetBillingTag(), context);

olp-cpp-sdk-dataservice-read/tests/CatalogRepositoryTest.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ TEST_F(CatalogRepositoryTest, GetLatestVersionCacheOnlyNotFound) {
156156
auto response = repository.GetLatestVersion(request, context);
157157

158158
EXPECT_FALSE(response.IsSuccessful());
159+
EXPECT_EQ(response.GetError().GetErrorCode(),
160+
olp::client::ErrorCode::NotFound);
159161
}
160162

161163
TEST_F(CatalogRepositoryTest, GetLatestVersionOnlineOnlyNotFound) {

0 commit comments

Comments
 (0)