From 5de42570e28f7b6163cae6986297b856314482c0 Mon Sep 17 00:00:00 2001 From: Anton Kolesnyk <41349689+antkmsft@users.noreply.github.com> Date: Fri, 17 Dec 2021 13:56:01 -0800 Subject: [PATCH] Make Template to pass the default goals set for code coverage (#3198) Co-authored-by: Anton Kolesnyk --- .../inc/azure/template/template_client.hpp | 1 + sdk/template/azure-template/src/template_client.cpp | 10 ++++++++++ sdk/template/azure-template/test/ut/template_test.cpp | 9 +++++++++ sdk/template/ci.yml | 7 ------- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/sdk/template/azure-template/inc/azure/template/template_client.hpp b/sdk/template/azure-template/inc/azure/template/template_client.hpp index 78c7762ce..dc17db082 100644 --- a/sdk/template/azure-template/inc/azure/template/template_client.hpp +++ b/sdk/template/azure-template/inc/azure/template/template_client.hpp @@ -10,6 +10,7 @@ namespace Azure { namespace Template { class TemplateClient final { public: std::string ClientVersion() const; + int GetValue(int key) const; }; }} // namespace Azure::Template diff --git a/sdk/template/azure-template/src/template_client.cpp b/sdk/template/azure-template/src/template_client.cpp index df04dc3df..9443847ab 100644 --- a/sdk/template/azure-template/src/template_client.cpp +++ b/sdk/template/azure-template/src/template_client.cpp @@ -11,3 +11,13 @@ using namespace Azure::Template; using namespace Azure::Template::_detail; std::string TemplateClient::ClientVersion() const { return PackageVersion::ToString(); } + +int TemplateClient::GetValue(int key) const +{ + if (key < 0) + { + return 0; + } + + return key + 1; +} diff --git a/sdk/template/azure-template/test/ut/template_test.cpp b/sdk/template/azure-template/test/ut/template_test.cpp index f31a36ea3..044d0fa48 100644 --- a/sdk/template/azure-template/test/ut/template_test.cpp +++ b/sdk/template/azure-template/test/ut/template_test.cpp @@ -13,3 +13,12 @@ TEST(Template, Basic) EXPECT_FALSE(templateClient.ClientVersion().empty()); } + +TEST(Template, GetValue) +{ + TemplateClient templateClient; + + EXPECT_EQ(templateClient.GetValue(-1), 0); + EXPECT_EQ(templateClient.GetValue(0), 1); + EXPECT_EQ(templateClient.GetValue(1), 2); +} diff --git a/sdk/template/ci.yml b/sdk/template/ci.yml index 8f81c49af..fece1b1b9 100644 --- a/sdk/template/ci.yml +++ b/sdk/template/ci.yml @@ -27,13 +27,6 @@ stages: parameters: ServiceDirectory: template CtestRegex: azure-template - # The azure-template project has lower branch coverage than the default. - # This overrides the branch coverage floor until the issue can be - # addressed. Once it is addressed this line should be removed so that - # projects generated from this ci.yml file don't set a coverage target - # that is lower than the baseline defined in archetype-sdk-client.yml - # Issue: https://github.com/Azure/azure-sdk-for-cpp/issues/3022 - BranchCoverageTarget: 33 Artifacts: - Name: azure-template Path: azure-template