-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reopen Tests ARM, test case for CheckNameAvailability operations.
- Loading branch information
Showing
6 changed files
with
202 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...l-ranch-specs/http/azure/resource-manager/operation-templates/check-name-availability.tsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import "@typespec/http"; | ||
import "@typespec/rest"; | ||
import "@azure-tools/typespec-azure-core"; | ||
import "@azure-tools/typespec-azure-resource-manager"; | ||
|
||
using TypeSpec.Http; | ||
using TypeSpec.Rest; | ||
using Azure.Core; | ||
using Azure.ResourceManager; | ||
using TypeSpec.OpenAPI; | ||
|
||
namespace Azure.ResourceManager.OperationTemplates; | ||
|
||
interface CheckNameAvailability { | ||
@scenario | ||
@scenarioDoc(""" | ||
Resource POST operation. | ||
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.OperationTemplates/checkNameAvailability | ||
Expected query parameter: api-version=2023-12-01-preview | ||
Expected request body: | ||
```json | ||
{ | ||
"name": "checkName", | ||
"type": "Microsoft.Web/site" | ||
} | ||
``` | ||
Expected response body: | ||
```json | ||
{ | ||
"nameAvailable": false, | ||
"reason": "AlreadyExists", | ||
"message": "Hostname 'checkName' already exists. Please select a different name." | ||
} | ||
``` | ||
""") | ||
checkGlobal is checkGlobalNameAvailability; | ||
|
||
@scenario | ||
@scenarioDoc(""" | ||
Resource POST operation. | ||
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.OperationTemplates/locations/westus/checkNameAvailability | ||
Expected query parameter: api-version=2023-12-01-preview | ||
Expected request body: | ||
```json | ||
{ | ||
"name": "checkName", | ||
"type": "Microsoft.Web/site", | ||
} | ||
``` | ||
Expected response body: | ||
```json | ||
{ | ||
"nameAvailable": false, | ||
"reason": "AlreadyExists", | ||
"message": "Hostname 'checkName' already exists. Please select a different name." | ||
} | ||
``` | ||
""") | ||
checkLocal is checkLocalNameAvailability; | ||
} |
30 changes: 30 additions & 0 deletions
30
packages/cadl-ranch-specs/http/azure/resource-manager/operation-templates/main.tsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import "@azure-tools/cadl-ranch-expect"; | ||
import "@typespec/http"; | ||
import "@typespec/rest"; | ||
import "@typespec/versioning"; | ||
import "@azure-tools/typespec-azure-core"; | ||
import "@azure-tools/typespec-azure-resource-manager"; | ||
import "@azure-tools/typespec-client-generator-core"; | ||
import "./check-name-availability.tsp"; | ||
|
||
using TypeSpec.Http; | ||
using TypeSpec.Rest; | ||
using TypeSpec.Versioning; | ||
using Azure.Core; | ||
using Azure.ResourceManager; | ||
using TypeSpec.OpenAPI; | ||
|
||
@armProviderNamespace | ||
@service | ||
@versioned(Versions) | ||
@doc("Arm Resource Provider management API.") | ||
namespace Azure.ResourceManager.OperationTemplates; | ||
|
||
@doc("Azure API versions.") | ||
enum Versions { | ||
@armCommonTypesVersion(CommonTypes.Versions.v5) | ||
@useDependency(Azure.Core.Versions.v1_0_Preview_2) | ||
@useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) | ||
@doc("Preview API version 2023-12-01-preview.") | ||
v2023_12_01_preview: "2023-12-01-preview", | ||
} |
60 changes: 60 additions & 0 deletions
60
packages/cadl-ranch-specs/http/azure/resource-manager/operation-templates/mockapi.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { passOnSuccess, json } from "@azure-tools/cadl-ranch-api"; | ||
import { ScenarioMockApi } from "@azure-tools/cadl-ranch-api"; | ||
|
||
export const Scenarios: Record<string, ScenarioMockApi> = {}; | ||
|
||
const SUBSCRIPTION_ID_EXPECTED = "00000000-0000-0000-0000-000000000000"; | ||
const validCheckNameAvailability = { | ||
nameAvailable: true, | ||
reason: "AlreadyExists", | ||
message: "", | ||
}; | ||
|
||
// Check Global Name Availability | ||
Scenarios.Azure_ResourceManager_OperationTemplates_CheckNameAvailability_checkGlobal = passOnSuccess({ | ||
uri: "/subscriptions/:subscriptionId/providers/Azure.ResourceManager.OperationTemplates/checkNameAvailability", | ||
method: "post", | ||
request: { | ||
params: { | ||
"subscriptionId": SUBSCRIPTION_ID_EXPECTED, | ||
"api-version": "2023-12-01-preview", | ||
}, | ||
body: { | ||
name: "checkName", | ||
type: "Microsoft.Web/site", | ||
}, | ||
}, | ||
response: { | ||
status: 200, | ||
body: json({ | ||
...validCheckNameAvailability, | ||
message: "This is a global name availability check message.", | ||
}), | ||
}, | ||
kind: "MockApiDefinition", | ||
}); | ||
|
||
// Check Local Name Availability | ||
Scenarios.Azure_ResourceManager_OperationTemplates_CheckNameAvailability_checkLocal = passOnSuccess({ | ||
uri: "/subscriptions/:subscriptionId/providers/Azure.ResourceManager.OperationTemplates/locations/:location/checkNameAvailability", | ||
method: "post", | ||
request: { | ||
params: { | ||
"subscriptionId": SUBSCRIPTION_ID_EXPECTED, | ||
"location": "westus", | ||
"api-version": "2023-12-01-preview", | ||
}, | ||
body: { | ||
name: "checkName", | ||
type: "Microsoft.Web/site", | ||
}, | ||
}, | ||
response: { | ||
status: 200, | ||
body: json({ | ||
...validCheckNameAvailability, | ||
message: "This is a local name availability check message.", | ||
}), | ||
}, | ||
kind: "MockApiDefinition", | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters