Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests for ARM, test case for resource action #679

Merged
merged 8 commits into from
Aug 13, 2024
5 changes: 5 additions & 0 deletions .changeset/funny-toes-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@azure-tools/cadl-ranch-specs": patch
---

Added tests for ARM, test case for resource action.
16 changes: 16 additions & 0 deletions packages/cadl-ranch-specs/cadl-ranch-summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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>;
}
Loading