Resolved File test issue. (#844)

This commit is contained in:
Kan Tang 2020-10-26 10:19:22 +08:00 committed by GitHub
parent c6d2505f9b
commit 26ad18c6e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 15 deletions

View File

@ -3,7 +3,7 @@
## 1.0.0-beta.5 (Unreleased)
### Breaking Changes
* `Azure::Storage::Files::Shares::Metrics::IncludeAPIs` is now renamed to `Azure::Storage::Files::Shares::Metrics::IncludeApis`, and is changed to a nullable member.
* Move header `azure/storage/files/shares/shares.hpp` to `azure/storage/files/shares.hpp`

View File

@ -566,8 +566,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
{
std::string Version; // The version of Storage Analytics to configure.
bool Enabled = bool(); // Indicates whether metrics are enabled for the File service.
bool IncludeAPIs = bool(); // Indicates whether metrics should generate summary statistics for
// called API operations.
Azure::Core::Nullable<bool> IncludeApis; // Indicates whether metrics should generate summary
// statistics for called API operations.
ShareRetentionPolicy RetentionPolicy;
};
@ -1372,9 +1372,13 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
writer.Write(XmlNode{XmlNodeType::StartTag, "Enabled"});
writer.Write(XmlNode{XmlNodeType::Text, nullptr, object.Enabled ? "true" : "false"});
writer.Write(XmlNode{XmlNodeType::EndTag});
writer.Write(XmlNode{XmlNodeType::StartTag, "IncludeAPIs"});
writer.Write(XmlNode{XmlNodeType::Text, nullptr, object.IncludeAPIs ? "true" : "false"});
writer.Write(XmlNode{XmlNodeType::EndTag});
if (object.IncludeApis.HasValue())
{
writer.Write(XmlNode{XmlNodeType::StartTag, "IncludeAPIs"});
writer.Write(XmlNode{
XmlNodeType::Text, nullptr, object.IncludeApis.GetValue() ? "true" : "false"});
writer.Write(XmlNode{XmlNodeType::EndTag});
}
writer.Write(XmlNode{XmlNodeType::StartTag, "RetentionPolicy"});
ShareRetentionPolicyToXml(writer, object.RetentionPolicy);
writer.Write(XmlNode{XmlNodeType::EndTag});
@ -1605,7 +1609,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
}
else if (path.size() == 1 && path[0] == XmlTagName::c_IncludeAPIs)
{
result.IncludeAPIs = (std::strcmp(node.Value, "true") == 0);
result.IncludeApis = (std::strcmp(node.Value, "true") == 0);
}
else if (path.size() == 1 && path[0] == XmlTagName::c_Version)
{

View File

@ -8,6 +8,16 @@
namespace Azure { namespace Storage { namespace Test {
namespace {
bool NullableEquals(
const Azure::Core::Nullable<bool>& lhs,
const Azure::Core::Nullable<bool>& rhs)
{
return (lhs.HasValue() && rhs.HasValue() && (lhs.GetValue() == rhs.GetValue()))
|| (!lhs.HasValue() && !rhs.HasValue());
}
} // namespace
const size_t c_SHARE_TEST_SIZE = 5;
std::shared_ptr<Files::Shares::ServiceClient>
@ -153,12 +163,12 @@ namespace Azure { namespace Storage { namespace Test {
properties.HourMetrics.Enabled = true;
properties.HourMetrics.RetentionPolicy.Enabled = true;
properties.HourMetrics.RetentionPolicy.Days = 4;
properties.HourMetrics.IncludeAPIs = true;
properties.HourMetrics.IncludeApis = true;
properties.MinuteMetrics.Enabled = true;
properties.MinuteMetrics.RetentionPolicy.Enabled = true;
properties.MinuteMetrics.RetentionPolicy.Days = 3;
properties.MinuteMetrics.IncludeAPIs = true;
properties.MinuteMetrics.IncludeApis = true;
Files::Shares::CorsRule corsRule;
corsRule.AllowedOrigins = "http://www.example1.com";
@ -183,7 +193,8 @@ namespace Azure { namespace Storage { namespace Test {
EXPECT_EQ(downloadedProperties.HourMetrics.Version, properties.HourMetrics.Version);
EXPECT_EQ(downloadedProperties.HourMetrics.Enabled, properties.HourMetrics.Enabled);
EXPECT_EQ(downloadedProperties.HourMetrics.IncludeAPIs, properties.HourMetrics.IncludeAPIs);
EXPECT_TRUE(NullableEquals(
downloadedProperties.HourMetrics.IncludeApis, properties.HourMetrics.IncludeApis));
EXPECT_EQ(
downloadedProperties.HourMetrics.RetentionPolicy.Enabled,
properties.HourMetrics.RetentionPolicy.Enabled);
@ -199,7 +210,8 @@ namespace Azure { namespace Storage { namespace Test {
EXPECT_EQ(downloadedProperties.MinuteMetrics.Version, properties.MinuteMetrics.Version);
EXPECT_EQ(downloadedProperties.MinuteMetrics.Enabled, properties.MinuteMetrics.Enabled);
EXPECT_EQ(downloadedProperties.MinuteMetrics.IncludeAPIs, properties.MinuteMetrics.IncludeAPIs);
EXPECT_TRUE(NullableEquals(
downloadedProperties.HourMetrics.IncludeApis, properties.HourMetrics.IncludeApis));
EXPECT_EQ(
downloadedProperties.MinuteMetrics.RetentionPolicy.Enabled,
properties.MinuteMetrics.RetentionPolicy.Enabled);
@ -242,12 +254,12 @@ namespace Azure { namespace Storage { namespace Test {
properties.HourMetrics.Enabled = true;
properties.HourMetrics.RetentionPolicy.Enabled = true;
properties.HourMetrics.RetentionPolicy.Days = 4;
properties.HourMetrics.IncludeAPIs = true;
properties.HourMetrics.IncludeApis = true;
properties.MinuteMetrics.Enabled = true;
properties.MinuteMetrics.RetentionPolicy.Enabled = true;
properties.MinuteMetrics.RetentionPolicy.Days = 3;
properties.MinuteMetrics.IncludeAPIs = true;
properties.MinuteMetrics.IncludeApis = true;
Files::Shares::CorsRule corsRule;
corsRule.AllowedOrigins = "http://www.example1.com";
@ -276,7 +288,8 @@ namespace Azure { namespace Storage { namespace Test {
EXPECT_EQ(downloadedProperties.HourMetrics.Version, properties.HourMetrics.Version);
EXPECT_EQ(downloadedProperties.HourMetrics.Enabled, properties.HourMetrics.Enabled);
EXPECT_EQ(downloadedProperties.HourMetrics.IncludeAPIs, properties.HourMetrics.IncludeAPIs);
EXPECT_TRUE(NullableEquals(
downloadedProperties.HourMetrics.IncludeApis, properties.HourMetrics.IncludeApis));
EXPECT_EQ(
downloadedProperties.HourMetrics.RetentionPolicy.Enabled,
properties.HourMetrics.RetentionPolicy.Enabled);
@ -292,7 +305,8 @@ namespace Azure { namespace Storage { namespace Test {
EXPECT_EQ(downloadedProperties.MinuteMetrics.Version, properties.MinuteMetrics.Version);
EXPECT_EQ(downloadedProperties.MinuteMetrics.Enabled, properties.MinuteMetrics.Enabled);
EXPECT_EQ(downloadedProperties.MinuteMetrics.IncludeAPIs, properties.MinuteMetrics.IncludeAPIs);
EXPECT_TRUE(NullableEquals(
downloadedProperties.HourMetrics.IncludeApis, properties.HourMetrics.IncludeApis));
EXPECT_EQ(
downloadedProperties.MinuteMetrics.RetentionPolicy.Enabled,
properties.MinuteMetrics.RetentionPolicy.Enabled);