Skip to content

Commit

Permalink
Introduce tags related test cases (Azure#36232)
Browse files Browse the repository at this point in the history
* update resourcemanager

* introduce test cases, but not fully working

* introduce a fix

* record all the new test cases
  • Loading branch information
ArcturusZhang authored May 30, 2023
1 parent bf70c8e commit e05fa0b
Show file tree
Hide file tree
Showing 73 changed files with 59,326 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,23 @@ public async Task PlacementGroupId()
Assert.AreEqual(removeIdResult, newRemoveIdResult);
Assert.AreEqual(removeIdResult, newRemoveOuterIdResult);
}

[RecordedTest]
[TestCase(null)]
[TestCase(true)]
[TestCase(false)]
public async Task SetTags(bool? useTagResource)
{
SetTagResourceUsage(Client, useTagResource);
var name = Recording.GenerateAssetName("aset-");
var aset = await CreateAvailabilitySetAsync(name);
var tags = new Dictionary<string, string>()
{
{ "key", "value" }
};
AvailabilitySetResource updated = await aset.SetTagsAsync(tags);

Assert.AreEqual(tags, updated.Data.Tags);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System.Collections.Generic;
using System.Threading.Tasks;
using Azure.Core.TestFramework;
using Azure.ResourceManager.Compute.Tests.Helpers;
Expand Down Expand Up @@ -42,5 +43,23 @@ public async Task Get()

ResourceDataHelper.AssertGroup(group1.Data, group2.Data);
}

[RecordedTest]
[TestCase(null)]
[TestCase(true)]
[TestCase(false)]
public async Task SetTags(bool? useTagResource)
{
SetTagResourceUsage(Client, useTagResource);
var name = Recording.GenerateAssetName("testDHG-");
var group = await CreateDedicatedHostGroupAsync(name);
var tags = new Dictionary<string, string>()
{
{ "key", "value" }
};
DedicatedHostGroupResource updated = await group.SetTagsAsync(tags);

Assert.AreEqual(tags, updated.Data.Tags);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System.Collections.Generic;
using System.Threading.Tasks;
using Azure.Core.TestFramework;
using Azure.ResourceManager.Compute.Models;
Expand Down Expand Up @@ -69,5 +70,23 @@ public async Task Update()

Assert.AreEqual(updatedAutoReplaceOnFailure, updatedHost.Data.AutoReplaceOnFailure);
}

[RecordedTest]
[TestCase(null)]
[TestCase(true)]
[TestCase(false)]
public async Task SetTags(bool? useTagResource)
{
SetTagResourceUsage(Client, useTagResource);
var name = Recording.GenerateAssetName("testHost-");
var host = await CreateDedicatedHostAsync(name);
var tags = new Dictionary<string, string>()
{
{ "key", "value" }
};
DedicatedHostResource updated = await host.SetTagsAsync(tags);

Assert.AreEqual(tags, updated.Data.Tags);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System.Collections.Generic;
using System.Threading.Tasks;
using Azure.Core.TestFramework;
using Azure.ResourceManager.Compute.Tests.Helpers;
Expand Down Expand Up @@ -42,5 +43,23 @@ public async Task Get()

ResourceDataHelper.AssertDiskAccess(access1.Data, access2.Data);
}

[RecordedTest]
[TestCase(null)]
[TestCase(true)]
[TestCase(false)]
public async Task SetTags(bool? useTagResource)
{
SetTagResourceUsage(Client, useTagResource);
var name = Recording.GenerateAssetName("testDA-");
var diskAccess = await CreateDiskAccessAsync(name);
var tags = new Dictionary<string, string>()
{
{ "key", "value" }
};
DiskAccessResource updated = await diskAccess.SetTagsAsync(tags);

Assert.AreEqual(tags, updated.Data.Tags);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public async Task Update()
Assert.AreEqual(description, updatedGalleryImage.Data.Description);
}

[RecordedTest]
[TestCase(null)]
[TestCase(true)]
[TestCase(false)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public async Task Update()
Assert.AreEqual(description, updatedGallery.Data.Description);
}

[RecordedTest]
[TestCase(null)]
[TestCase(true)]
[TestCase(false)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,23 @@ public async Task Update()

Assert.AreEqual(newDiskSize, updatedDisk.Data.DiskSizeGB);
}

[RecordedTest]
[TestCase(null)]
[TestCase(true)]
[TestCase(false)]
public async Task SetTags(bool? useTagResource)
{
SetTagResourceUsage(Client, useTagResource);
var name = Recording.GenerateAssetName("testDisk-");
var disk = await CreateDiskAsync(name);
var tags = new Dictionary<string, string>()
{
{ "key", "value" }
};
ManagedDiskResource updated = await disk.SetTagsAsync(tags);

Assert.AreEqual(tags, updated.Data.Tags);
}
}
}
Loading

0 comments on commit e05fa0b

Please sign in to comment.