Skip to content

Commit

Permalink
Reopen Test ARM, test case for location-based resource
Browse files Browse the repository at this point in the history
  • Loading branch information
v-hongli1 committed Nov 5, 2024
1 parent 84f74ee commit fe79662
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 35 deletions.
22 changes: 11 additions & 11 deletions packages/cadl-ranch-specs/cadl-ranch-summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -912,8 +912,8 @@ Expected response body:
- Endpoint: `put https://management.azure.com`

Resource PUT operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Resources/locationResources/resource
Expected query parameter: api-version=2023-12-01-preview
Expected path: /subscriptions/-00000001-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/locations/eastus/locationResources/resource
Expected query parameter: api-version=2022-12-01-preview
Expected request body:

```json
Expand All @@ -928,12 +928,12 @@ Expected response body:

```json
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Resources/locationResources/resource",
"id": "/subscriptions/-00000001-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/locations/eastus/locationResources/resource",
"name": "resource",
"type": "Azure.ResourceManager.Resources/locationResources",
"properties": {
"description": "valid",
"provisioningState": "Succeeded"
"provisioningState": "Succeeded",
},
"systemData": {
"createdBy": "AzureSDK",
Expand All @@ -951,7 +951,7 @@ Expected response body:
- Endpoint: `delete https://management.azure.com`

Resource DELETE operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Resources/locationResources/resource
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/locations/eastus/locationResources/resource
Expected query parameter: api-version=2023-12-01-preview

````
Expand All @@ -962,13 +962,13 @@ Expected response status code: 204
- Endpoint: `get https://management.azure.com`
Resource GET operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Resources/locationResources/resource
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/locations/eastus/locationResources/resource
Expected query parameter: api-version=2023-12-01-preview
Expected response body:
```json
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Resources/locationResources/resource",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/locations/eastus/locationResources/resource",
"name": "resource",
"type": "Azure.ResourceManager.Resources/locationResources",
"properties":{
Expand All @@ -991,15 +991,15 @@ Expected response body:
- Endpoint: `get https://management.azure.com`

Resource LIST by resource group operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Resources/locationResources
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/locations/eastus/locationResources
Expected query parameter: api-version=2023-12-01-preview

Expected response body:

```json
{
"value": [{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Resources/locationResources/resource",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/locations/eastus/locationResources/resource",
"name": "resource",
"type": "Azure.ResourceManager.Resources/locationResources",
"properties":{
Expand All @@ -1023,7 +1023,7 @@ Expected response body:
- Endpoint: `patch https://management.azure.com`

Resource PATCH operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Resources/locationResources/resource
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/locations/eastus/locationResources/resource
Expected query parameter: api-version=2023-12-01-preview
Expected request body:

Expand All @@ -1039,7 +1039,7 @@ Expected response body:

```json
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Resources/locationResources/resource",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/locations/eastus/locationResources/resource",
"name": "resource",
"type": "Azure.ResourceManager.Resources/locationResources",
"properties":{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ using TypeSpec.OpenAPI;

namespace Azure.ResourceManager.Resources;

@locationResource
@resource("locationResources")
@parentResource(ResourceGroupLocationResource)
model LocationResource is ProxyResource<LocationResourceProperties> {
...ResourceNameParameter<LocationResource>;
}
Expand All @@ -31,13 +32,13 @@ interface LocationResources {
@scenario
@scenarioDoc("""
Resource GET operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Resources/locationResources/resource
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/locations/eastus/locationResources/resource
Expected query parameter: api-version=2023-12-01-preview

Expected response body:
```json
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Resources/locationResources/resource",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/locations/eastus/locationResources/resource",
"name": "resource",
"type": "Azure.ResourceManager.Resources/locationResources",
"properties":{
Expand All @@ -60,8 +61,8 @@ interface LocationResources {
@scenario
@scenarioDoc("""
Resource PUT operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Resources/locationResources/resource
Expected query parameter: api-version=2023-12-01-preview
Expected path: /subscriptions/-00000001-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/locations/eastus/locationResources/resource
Expected query parameter: api-version=2022-12-01-preview
Expected request body:
```json
{
Expand All @@ -73,12 +74,12 @@ interface LocationResources {
Expected response body:
```json
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Resources/locationResources/resource",
"id": "/subscriptions/-00000001-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/locations/eastus/locationResources/resource",
"name": "resource",
"type": "Azure.ResourceManager.Resources/locationResources",
"properties": {
"description": "valid",
"provisioningState": "Succeeded"
"provisioningState": "Succeeded",
},
"systemData": {
"createdBy": "AzureSDK",
Expand All @@ -96,7 +97,7 @@ interface LocationResources {
@scenario
@scenarioDoc("""
Resource PATCH operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Resources/locationResources/resource
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/locations/eastus/locationResources/resource
Expected query parameter: api-version=2023-12-01-preview
Expected request body:
```json
Expand All @@ -109,7 +110,7 @@ interface LocationResources {
Expected response body:
```json
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Resources/locationResources/resource",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/locations/eastus/locationResources/resource",
"name": "resource",
"type": "Azure.ResourceManager.Resources/locationResources",
"properties":{
Expand All @@ -132,7 +133,7 @@ interface LocationResources {
@scenario
@scenarioDoc("""
Resource DELETE operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Resources/locationResources/resource
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/locations/eastus/locationResources/resource
Expected query parameter: api-version=2023-12-01-preview
```
Expected response status code: 204
Expand All @@ -142,14 +143,14 @@ interface LocationResources {
@scenario
@scenarioDoc("""
Resource LIST by resource group operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Resources/locationResources
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/locations/eastus/locationResources
Expected query parameter: api-version=2023-12-01-preview

Expected response body:
```json
{
"value": [{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Resources/locationResources/resource",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/locations/eastus/locationResources/resource",
"name": "resource",
"type": "Azure.ResourceManager.Resources/locationResources",
"properties":{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ const validSingletonResource = {
},
};

const validLocationResource = {
id: `/subscriptions/${SUBSCRIPTION_ID_EXPECTED}/locations/${LOCATION_EXPECTED}/providers/Azure.ResourceManager.Resources/locationResources/resource`,
const validResourceGroupLocationResource = {
id: `/subscriptions/${SUBSCRIPTION_ID_EXPECTED}/resourceGroups/${RESOURCE_GROUP_EXPECTED}/providers/Azure.ResourceManager.Resources/locations/${LOCATION_EXPECTED}/locationResources/resource`,
name: "resource",
type: "Azure.ResourceManager.Resources/locationResources",
properties: {
Expand All @@ -80,31 +80,33 @@ const validLocationResource = {
},
};

// location tracked resource
// location resource
Scenarios.Azure_ResourceManager_Resources_LocationResources_get = passOnSuccess({
uri: "/subscriptions/:subscriptionId/locations/:location/providers/Azure.ResourceManager.Resources/locationResources/:locationResourceName",
uri: "/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Resources/locations/:location/locationResources/:locationResourceName",
method: "get",
request: {
params: {
"subscriptionId": SUBSCRIPTION_ID_EXPECTED,
"resourceGroup": RESOURCE_GROUP_EXPECTED,
"location": LOCATION_EXPECTED,
"locationResourceName": "resource",
"api-version": "2023-12-01-preview",
},
},
response: {
status: 200,
body: json(validLocationResource),
body: json(validResourceGroupLocationResource),
},
kind: "MockApiDefinition",
});

Scenarios.Azure_ResourceManager_Resources_LocationResources_createOrUpdate = passOnSuccess({
uri: "/subscriptions/:subscriptionId/locations/:location/providers/Azure.ResourceManager.Resources/locationResources/:locationResourceName",
uri: "/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Resources/locations/:location/locationResources/:locationResourceName",
method: "put",
request: {
params: {
"subscriptionId": SUBSCRIPTION_ID_EXPECTED,
"resourceGroup": RESOURCE_GROUP_EXPECTED,
"location": LOCATION_EXPECTED,
"locationResourceName": "resource",
"api-version": "2023-12-01-preview",
Expand All @@ -117,17 +119,18 @@ Scenarios.Azure_ResourceManager_Resources_LocationResources_createOrUpdate = pas
},
response: {
status: 200,
body: json(validLocationResource),
body: json(validResourceGroupLocationResource),
},
kind: "MockApiDefinition",
});

Scenarios.Azure_ResourceManager_Resources_LocationResources_update = passOnSuccess({
uri: "/subscriptions/:subscriptionId/locations/:location/providers/Azure.ResourceManager.Resources/locationResources/:locationResourceName",
uri: "/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Resources/locations/:location/locationResources/:locationResourceName",
method: "patch",
request: {
params: {
"subscriptionId": SUBSCRIPTION_ID_EXPECTED,
"resourceGroup": RESOURCE_GROUP_EXPECTED,
"location": LOCATION_EXPECTED,
"locationResourceName": "resource",
"api-version": "2023-12-01-preview",
Expand All @@ -144,7 +147,7 @@ Scenarios.Azure_ResourceManager_Resources_LocationResources_update = passOnSucce
response: {
status: 200,
body: json({
...validLocationResource,
...validResourceGroupLocationResource,
properties: {
provisioningState: "Succeeded",
description: "valid2",
Expand All @@ -155,11 +158,12 @@ Scenarios.Azure_ResourceManager_Resources_LocationResources_update = passOnSucce
});

Scenarios.Azure_ResourceManager_Resources_LocationResources_delete = passOnSuccess({
uri: "/subscriptions/:subscriptionId/locations/:location/providers/Azure.ResourceManager.Resources/locationResources/:locationResourceName",
uri: "/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Resources/locations/:location/locationResources/:locationResourceName",
method: "delete",
request: {
params: {
"subscriptionId": SUBSCRIPTION_ID_EXPECTED,
"resourceGroup": RESOURCE_GROUP_EXPECTED,
"location": LOCATION_EXPECTED,
"locationResourceName": "resource",
"api-version": "2023-12-01-preview",
Expand All @@ -172,19 +176,20 @@ Scenarios.Azure_ResourceManager_Resources_LocationResources_delete = passOnSucce
});

Scenarios.Azure_ResourceManager_Resources_LocationResources_listByParent = passOnSuccess({
uri: "/subscriptions/:subscriptionId/locations/:location/providers/Azure.ResourceManager.Resources/locationResources",
uri: "/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Resources/locations/:location/locationResources",
method: "get",
request: {
params: {
"subscriptionId": SUBSCRIPTION_ID_EXPECTED,
"resourceGroup": RESOURCE_GROUP_EXPECTED,
"location": LOCATION_EXPECTED,
"api-version": "2023-12-01-preview",
},
},
response: {
status: 200,
body: json({
value: [validLocationResource],
value: [validResourceGroupLocationResource],
}),
},
kind: "MockApiDefinition",
Expand Down

0 comments on commit fe79662

Please sign in to comment.