Skip to content

Commit e05fa0b

Browse files
Introduce tags related test cases (#36232)
* update resourcemanager * introduce test cases, but not fully working * introduce a fix * record all the new test cases
1 parent bf70c8e commit e05fa0b

File tree

73 files changed

+59326
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+59326
-0
lines changed

sdk/compute/Azure.ResourceManager.Compute/tests/Scenario/AvailabilitySetOperationsTests.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,5 +124,23 @@ public async Task PlacementGroupId()
124124
Assert.AreEqual(removeIdResult, newRemoveIdResult);
125125
Assert.AreEqual(removeIdResult, newRemoveOuterIdResult);
126126
}
127+
128+
[RecordedTest]
129+
[TestCase(null)]
130+
[TestCase(true)]
131+
[TestCase(false)]
132+
public async Task SetTags(bool? useTagResource)
133+
{
134+
SetTagResourceUsage(Client, useTagResource);
135+
var name = Recording.GenerateAssetName("aset-");
136+
var aset = await CreateAvailabilitySetAsync(name);
137+
var tags = new Dictionary<string, string>()
138+
{
139+
{ "key", "value" }
140+
};
141+
AvailabilitySetResource updated = await aset.SetTagsAsync(tags);
142+
143+
Assert.AreEqual(tags, updated.Data.Tags);
144+
}
127145
}
128146
}

sdk/compute/Azure.ResourceManager.Compute/tests/Scenario/DedicatedHostGroupOperationsTests.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4+
using System.Collections.Generic;
45
using System.Threading.Tasks;
56
using Azure.Core.TestFramework;
67
using Azure.ResourceManager.Compute.Tests.Helpers;
@@ -42,5 +43,23 @@ public async Task Get()
4243

4344
ResourceDataHelper.AssertGroup(group1.Data, group2.Data);
4445
}
46+
47+
[RecordedTest]
48+
[TestCase(null)]
49+
[TestCase(true)]
50+
[TestCase(false)]
51+
public async Task SetTags(bool? useTagResource)
52+
{
53+
SetTagResourceUsage(Client, useTagResource);
54+
var name = Recording.GenerateAssetName("testDHG-");
55+
var group = await CreateDedicatedHostGroupAsync(name);
56+
var tags = new Dictionary<string, string>()
57+
{
58+
{ "key", "value" }
59+
};
60+
DedicatedHostGroupResource updated = await group.SetTagsAsync(tags);
61+
62+
Assert.AreEqual(tags, updated.Data.Tags);
63+
}
4564
}
4665
}

sdk/compute/Azure.ResourceManager.Compute/tests/Scenario/DedicatedHostOperationsTests.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4+
using System.Collections.Generic;
45
using System.Threading.Tasks;
56
using Azure.Core.TestFramework;
67
using Azure.ResourceManager.Compute.Models;
@@ -69,5 +70,23 @@ public async Task Update()
6970

7071
Assert.AreEqual(updatedAutoReplaceOnFailure, updatedHost.Data.AutoReplaceOnFailure);
7172
}
73+
74+
[RecordedTest]
75+
[TestCase(null)]
76+
[TestCase(true)]
77+
[TestCase(false)]
78+
public async Task SetTags(bool? useTagResource)
79+
{
80+
SetTagResourceUsage(Client, useTagResource);
81+
var name = Recording.GenerateAssetName("testHost-");
82+
var host = await CreateDedicatedHostAsync(name);
83+
var tags = new Dictionary<string, string>()
84+
{
85+
{ "key", "value" }
86+
};
87+
DedicatedHostResource updated = await host.SetTagsAsync(tags);
88+
89+
Assert.AreEqual(tags, updated.Data.Tags);
90+
}
7291
}
7392
}

sdk/compute/Azure.ResourceManager.Compute/tests/Scenario/DiskAccessOperationsTests.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4+
using System.Collections.Generic;
45
using System.Threading.Tasks;
56
using Azure.Core.TestFramework;
67
using Azure.ResourceManager.Compute.Tests.Helpers;
@@ -42,5 +43,23 @@ public async Task Get()
4243

4344
ResourceDataHelper.AssertDiskAccess(access1.Data, access2.Data);
4445
}
46+
47+
[RecordedTest]
48+
[TestCase(null)]
49+
[TestCase(true)]
50+
[TestCase(false)]
51+
public async Task SetTags(bool? useTagResource)
52+
{
53+
SetTagResourceUsage(Client, useTagResource);
54+
var name = Recording.GenerateAssetName("testDA-");
55+
var diskAccess = await CreateDiskAccessAsync(name);
56+
var tags = new Dictionary<string, string>()
57+
{
58+
{ "key", "value" }
59+
};
60+
DiskAccessResource updated = await diskAccess.SetTagsAsync(tags);
61+
62+
Assert.AreEqual(tags, updated.Data.Tags);
63+
}
4564
}
4665
}

sdk/compute/Azure.ResourceManager.Compute/tests/Scenario/GalleryImageOperationsTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public async Task Update()
8181
Assert.AreEqual(description, updatedGalleryImage.Data.Description);
8282
}
8383

84+
[RecordedTest]
8485
[TestCase(null)]
8586
[TestCase(true)]
8687
[TestCase(false)]

sdk/compute/Azure.ResourceManager.Compute/tests/Scenario/GalleryOperationsTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public async Task Update()
6666
Assert.AreEqual(description, updatedGallery.Data.Description);
6767
}
6868

69+
[RecordedTest]
6970
[TestCase(null)]
7071
[TestCase(true)]
7172
[TestCase(false)]

sdk/compute/Azure.ResourceManager.Compute/tests/Scenario/ManagedDiskOperationsTests.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,23 @@ public async Task Update()
6262

6363
Assert.AreEqual(newDiskSize, updatedDisk.Data.DiskSizeGB);
6464
}
65+
66+
[RecordedTest]
67+
[TestCase(null)]
68+
[TestCase(true)]
69+
[TestCase(false)]
70+
public async Task SetTags(bool? useTagResource)
71+
{
72+
SetTagResourceUsage(Client, useTagResource);
73+
var name = Recording.GenerateAssetName("testDisk-");
74+
var disk = await CreateDiskAsync(name);
75+
var tags = new Dictionary<string, string>()
76+
{
77+
{ "key", "value" }
78+
};
79+
ManagedDiskResource updated = await disk.SetTagsAsync(tags);
80+
81+
Assert.AreEqual(tags, updated.Data.Tags);
82+
}
6583
}
6684
}

0 commit comments

Comments
 (0)