negative tests (#5497)

* negative tests

* fix test for live

* regen assets
This commit is contained in:
George Arama 2024-04-25 11:26:49 -07:00 committed by GitHub
parent ec9ffac6af
commit cd1cc41805
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 98 additions and 1 deletions

View File

@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "cpp",
"TagPrefix": "cpp/tables",
"Tag": "cpp/tables_f9b3c4948f"
"Tag": "cpp/tables_4152f4d311"
}

View File

@ -147,6 +147,18 @@ namespace Azure { namespace Data { namespace Test {
EXPECT_TRUE(createResponse.Value.Id.find(m_tableName) != std::string::npos);
}
TEST_P(TablesClientTest, CreateTableFail)
{
try
{
auto createResponse = m_tableServiceClient->CreateTable("+++");
}
catch (Azure::Core::RequestFailedException& e)
{
EXPECT_EQ(e.StatusCode, Azure::Core::Http::HttpStatusCode::BadRequest);
}
}
TEST_P(TablesClientTest, GetAccessPolicy_LIVEONLY_)
{
if (GetParam() != AuthType::ConnectionString)
@ -231,6 +243,18 @@ namespace Azure { namespace Data { namespace Test {
EXPECT_EQ(response.RawResponse->GetStatusCode(), Azure::Core::Http::HttpStatusCode::NoContent);
}
TEST_P(TablesClientTest, DeleteTableFail)
{
try
{
auto response = m_tableServiceClient->DeleteTable(m_tableName);
}
catch (Azure::Core::RequestFailedException& e)
{
EXPECT_EQ(e.StatusCode, Azure::Core::Http::HttpStatusCode::NotFound);
}
}
TEST_P(TablesClientTest, ServiceClientConstructors)
{
EXPECT_FALSE(m_tableServiceClient == nullptr);
@ -296,6 +320,39 @@ namespace Azure { namespace Data { namespace Test {
EXPECT_FALSE(response.Value.ETag.empty());
}
TEST_P(TablesClientTest, EntityCreateFail)
{
if (GetParam() == AuthType::Key)
{
EXPECT_TRUE(true);
return;
}
Azure::Data::Tables::Models::TableEntity entity;
entity.SetPartitionKey("P1");
entity.SetRowKey("R1");
entity.Properties["Name"] = TableEntityProperty("Azure");
entity.Properties["Product"] = TableEntityProperty("Tables");
auto createResponse = m_tableServiceClient->CreateTable(m_tableName);
{
auto response = m_tableClient->AddEntity(entity);
EXPECT_EQ(
response.RawResponse->GetStatusCode(), Azure::Core::Http::HttpStatusCode::NoContent);
EXPECT_FALSE(response.Value.ETag.empty());
}
{
try
{
auto response = m_tableClient->AddEntity(entity);
}
catch (Azure::Core::RequestFailedException& e)
{
EXPECT_EQ(e.StatusCode, Azure::Core::Http::HttpStatusCode::Conflict);
}
}
}
TEST_P(TablesClientTest, EntityUpdate)
{
if (GetParam() == AuthType::Key)
@ -399,6 +456,30 @@ namespace Azure { namespace Data { namespace Test {
updateResponse2.RawResponse->GetStatusCode(), Azure::Core::Http::HttpStatusCode::NoContent);
}
TEST_P(TablesClientTest, EntityDeleteFail)
{
if (GetParam() == AuthType::Key)
{
EXPECT_TRUE(true);
return;
}
Azure::Data::Tables::Models::TableEntity entity;
entity.SetPartitionKey("P1");
entity.SetRowKey("R1");
entity.Properties["Name"] = TableEntityProperty("Azure");
entity.Properties["Product"] = TableEntityProperty("Tables");
auto createResponse = m_tableServiceClient->CreateTable(m_tableName);
try
{
auto updateResponse2 = m_tableClient->DeleteEntity(entity);
}
catch (Azure::Core::RequestFailedException& e)
{
EXPECT_EQ(e.StatusCode, Azure::Core::Http::HttpStatusCode::NotFound);
}
}
TEST_P(TablesClientTest, EntityUpsert)
{
if (GetParam() == AuthType::Key)
@ -516,6 +597,22 @@ namespace Azure { namespace Data { namespace Test {
responseQuery.Value.Properties["Timestamp"].Type.Value(), TableEntityDataType::EdmDateTime);
}
TEST_P(TablesClientTest, EntityGetFail)
{
Azure::Data::Tables::Models::TableEntity entity;
std::string partitionKey = "P1";
std::string rowKey = "R1";
try
{
auto responseQuery = m_tableClient->GetEntity(partitionKey, rowKey);
}
catch (Azure::Core::RequestFailedException& e)
{
EXPECT_EQ(e.StatusCode, Azure::Core::Http::HttpStatusCode::NotFound);
}
}
TEST_P(TablesClientTest, TransactionCreateFail_LIVEONLY_)
{
if (GetParam() == AuthType::SAS)