Tests for ARM, test case for resource action (#679)

* Tests for ARM, test case for resource action
This commit is contained in:
Hong Li(MSFT) 2024-08-13 17:06:00 +08:00 коммит произвёл GitHub
Родитель 4a861c7839
Коммит 4022f01c7c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
4 изменённых файлов: 70 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,5 @@
---
"@azure-tools/cadl-ranch-specs": patch
---
Added tests for ARM, test case for resource action.

Просмотреть файл

@ -964,6 +964,22 @@ Expected response body:
}
```
### Azure_ResourceManager_Models_Resources_TopLevelTrackedResources_actionSync
- Endpoint: `post https://management.azure.com`
Resource sync action.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.Resources/topLevelTrackedResources/top/actionSync
Expected query parameter: api-version=2023-12-01-preview
Expected request body:
```json
{
"message": "Resource action at top level.",
"urgent": true
}
```
### Azure_ResourceManager_Models_Resources_TopLevelTrackedResources_createOrReplace
- Endpoint: `put https://management.azure.com`

Просмотреть файл

@ -42,6 +42,31 @@ const validNestedResource = {
},
};
Scenarios.Azure_ResourceManager_Models_Resources_TopLevelTrackedResources_actionSync = passOnSuccess([
mockapi.post(
"/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Models.Resources/topLevelTrackedResources/:topLevelResourceName/actionSync",
(req) => {
req.expect.containsQueryParam("api-version", "2023-12-01-preview");
if (req.params.subscriptionId !== SUBSCRIPTION_ID_EXPECTED) {
throw new ValidationError("Unexpected subscriptionId", SUBSCRIPTION_ID_EXPECTED, req.params.subscriptionId);
}
if (req.params.resourceGroup.toLowerCase() !== RESOURCE_GROUP_EXPECTED) {
throw new ValidationError("Unexpected resourceGroup", RESOURCE_GROUP_EXPECTED, req.params.resourceGroup);
}
if (req.params.topLevelResourceName.toLowerCase() !== "top") {
throw new ValidationError("Unexpected top level resource name", "top", req.params.topLevelResourceName);
}
req.expect.bodyEquals({
message: "Resource action at top level.",
urgent: true,
});
return {
status: 204,
};
},
),
]);
// top level tracked resource
Scenarios.Azure_ResourceManager_Models_Resources_TopLevelTrackedResources_get = passOnSuccess([
mockapi.get(

Просмотреть файл

@ -31,6 +31,15 @@ model TopLevelTrackedResourceProperties {
description?: string;
}
@doc("The details of a user notification.")
model NotificationDetails {
@doc("The notification message.")
message: string;
@doc("If true, the notification is urgent.")
urgent: boolean;
}
@armResourceOperations
interface TopLevelTrackedResources {
@scenario
@ -211,4 +220,19 @@ interface TopLevelTrackedResources {
```
""")
listBySubscription is ArmListBySubscription<TopLevelTrackedResource>;
@scenario
@scenarioDoc("""
Resource sync action.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.Resources/topLevelTrackedResources/top/actionSync
Expected query parameter: api-version=2023-12-01-preview
Expected request body:
```json
{
"message": "Resource action at top level.",
"urgent": true
}
```
""")
actionSync is ArmResourceActionNoContentSync<TopLevelTrackedResource, NotificationDetails>;
}