Skip to content

Commit

Permalink
Enable AutoRestUpgradeTest.ps1.
Browse files Browse the repository at this point in the history
  • Loading branch information
Youri committed Jul 20, 2020
1 parent 421018b commit 66c750d
Show file tree
Hide file tree
Showing 37 changed files with 770 additions and 1,397 deletions.
1 change: 1 addition & 0 deletions tests-upgrade/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
generate
generated
11 changes: 8 additions & 3 deletions tests-upgrade/AutoRestUpgradeTest.ps1
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
param([switch]$Generate,[string]$TestName,[switch]$M3,[switch]$M4,[switch]$AllowList,[switch]$BlackList)
#need to use the right version of node.js
# nvs use 10.16.0
#nvs use 10.16.0
# #please use substring to select the compare path
# $m3Path='.\generate\m3'
# $m4Path='.\generate\m4'
mkdir CompareResult
$scriptPath = Get-Location
$global:isError = $false
$conf = (Get-Content 'Configuration.json') | ConvertFrom-Json
Expand Down Expand Up @@ -60,6 +61,7 @@ function Generate()
autorest-beta --use:@autorest/powershell@2.1.386 --output-folder:.\generate\m3 --Debug
##generate m4 code
autorest-beta --use:..\..\ --output-folder:.\generate\m4 --Debug

}elseif($M3)
{
autorest-beta --use:@autorest/powershell@2.1.386 --output-folder:.\generate\m3 --Debug
Expand All @@ -80,8 +82,8 @@ function CompareTest([string]$inputm3Path,[string]$inputm4Path,[string]$testFile
$initFileList = Get-ChildItem -Recurse -force
# $initIgnoreFileList = $inputm3Path + '\generated\modules'
# $targetIgnoreFileList = $inputm4Path + '\generated\modules'
$initIgnoreFileList = (($inputm3Path+'\generated\modules'), ($inputm3Path+'\.gitignore'))
$targetIgnoreFileList = (($inputm4Path+'\generated\modules'), ($inputm4Path+'\.gitignore'))
$initIgnoreFileList = (($inputm3Path+'\generated\modules'), ($inputm3Path+'\.gitignore'),($inputm3Path+'\tools\Resources\.gitignore'))
$targetIgnoreFileList = (($inputm4Path+'\generated\modules'), ($inputm4Path+'\.gitignore'),($inputm4Path+'\tools\Resources\.gitignore'))
# $initFileList
#foreach initFileList and get the hashcode of them
foreach( $initFile in $initFileList)
Expand Down Expand Up @@ -281,4 +283,7 @@ cd $currentPath.Path
if($global:isError)
{
throw 'Error: The code generated by the target file is different from the code generated by the source file.'
}else
{
Write-Host -ForegroundColor blue 'All generated codes are the same'
}
35 changes: 34 additions & 1 deletion tests-upgrade/Configuration.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
{
"WhiteList":["basic-get","basic-get-delete"]
"WhiteList":[
"basic-disableazure-get",
"basic-disableazure-response"
],
"BlackList":[
"basic-get-querystr",
"basic-get-delete",
"basic-get-delete-put-patch",
"basic-request-methods",
"basic-get-response-operation",
"basic-response-multioperation",
"basic-response-defaultoperation",
"basic-disableazure-get",
"component-param",
"component-multiparam",
"component-param-remote",
"component--param-localremote",
"component-param-inbody",
"component-definitions-local",
"component-definitions-remote",
"component-definitions-combined",
"datamodels-datatypes-mixedtypes",
"datamodels-datatypes-integer",
"datamodels-datatypes-string",
"datamodels-datatypes-nullable",
"datamodels-datatypes-array",
"datamodels-datatypes-object",
"datamodels-datatypes-file",
"datamodels-datatypes-anytype",
"datamodels-enums",
"datamodels-keyvalue",
"datamodels-combineschema",
"datamodels-inheritpolymorphism"
]
}
13 changes: 13 additions & 0 deletions tests-upgrade/basic-disableazure-get/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### AutoRest Configuration
> see https://aka.ms/autorest
``` yaml
require:
- $(this-folder)/../readme.azure.noprofile.md

azure: false

input-file:
- $(this-folder)/swagger.json

```
53 changes: 53 additions & 0 deletions tests-upgrade/basic-disableazure-get/swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{

"swagger": "2.0",
"info": {
"title": "AutoRestUpgradeClient",
"version": "2018-04-01",
"description": "ARM AutoRestUpgrade"
},
"host": "management.azure.com",
"schemes": [
"https"
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"security": [
{
"azure_auth": [
"user_impersonation"
]
}
],
"securityDefinitions": {
"azure_auth": {
"type": "oauth2",
"authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize",
"flow": "implicit",
"description": "Azure Active Directory OAuth2 Flow",
"scopes": {
"user_impersonation": "impersonate your user account"
}
}
},
"paths": {
"/subscriptions/resourceGroup": {
"get": {
"tags": [
"Workspaces"
],
"operationId": "Workspaces_Get",
"description": "Gets the workspace.",
"responses": {
"200": {
"description": "Ok-Return"
}
}
}
}
}
}
13 changes: 13 additions & 0 deletions tests-upgrade/basic-disableazure-response/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### AutoRest Configuration
> see https://aka.ms/autorest
``` yaml
require:
- $(this-folder)/../readme.azure.noprofile.md

azure: false

input-file:
- $(this-folder)/swagger.json

```
61 changes: 61 additions & 0 deletions tests-upgrade/basic-disableazure-response/swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{

"swagger": "2.0",
"info": {
"title": "AutoRestUpgradeClient",
"version": "2018-04-01",
"description": "ARM AutoRestUpgrade"
},
"host": "management.azure.com",
"schemes": [
"https"
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"security": [
{
"azure_auth": [
"user_impersonation"
]
}
],
"securityDefinitions": {
"azure_auth": {
"type": "oauth2",
"authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize",
"flow": "implicit",
"description": "Azure Active Directory OAuth2 Flow",
"scopes": {
"user_impersonation": "impersonate your user account"
}
}
},
"paths": {
"/subscriptions/resourceGroup": {
"get": {
"tags": [
"Workspaces"
],
"operationId": "Workspaces_Get",
"description": "Gets the workspace.",
"responses": {
"200": {
"description": "Ok-Return",
"schema": {
"$ref": "#/definitions/Workspaces"
}
}
}
}
}
},
"definitions": {
"Workspaces": {
"type": "string"
}
}
}
16 changes: 8 additions & 8 deletions tests-upgrade/basic-get-delete-put-patch/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

"swagger": "2.0",
"info": {
"title": "DatabricksClient",
"title": "AutoRestUpgradeClient",
"version": "2018-04-01",
"description": "ARM Databricks"
"description": "ARM AutoRestUpgrade"
},
"host": "management.azure.com",
"schemes": [
Expand Down Expand Up @@ -43,8 +43,8 @@
"operationId": "Workspaces_Get",
"description": "Gets the workspace.",
"responses": {
"default": {
"description": "Error response describing why the operation failed."
"200": {
"description": "Ok-Return"
}
}
},
Expand All @@ -55,8 +55,8 @@
"operationId": "Workspaces_Delete",
"description": "Deletes the workspace",
"responses": {
"default": {
"description": "Error response describing why the operation failed."
"200": {
"description": "Ok-Return"
}
}
},
Expand All @@ -67,8 +67,8 @@
"operationId": "Workspaces_CreateOrUpdate",
"description": "Creates a new workspace.",
"responses": {
"default": {
"description": "Error response describing why the operation failed."
"200": {
"description": "Ok-Return"
}
}
},
Expand Down
12 changes: 6 additions & 6 deletions tests-upgrade/basic-get-delete/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"swagger": "2.0",
"info": {
"title": "DatabricksClient",
"title": "AutoRestUpgradeClient",
"version": "2018-04-01",
"description": "ARM Databricks"
},
Expand Down Expand Up @@ -43,8 +43,8 @@
"operationId": "Workspaces_Get",
"description": "Gets the workspace.",
"responses": {
"default": {
"description": "Error response describing why the operation failed."
"200": {
"description": "Ok-Return"
}
}
},
Expand All @@ -55,9 +55,9 @@
"operationId": "Workspaces_Delete",
"description": "Delete the workspace.",
"responses": {
"default": {
"description": "Error response describing why the operation failed."
}
"200": {
"description": "Ok-Return"
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests-upgrade/basic-get-response-operation/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
"200": {
"description": "OK - Returns the workspace."
},
"default": {
"description": "Error response describing why the operation failed."
"201": {
"description": "OK - Returns the workspace."
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions tests-upgrade/basic-get/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

"swagger": "2.0",
"info": {
"title": "DatabricksClient",
"title": "AutoRestUpgradeClient",
"version": "2018-04-01",
"description": "ARM Databricks"
"description": "ARM AutoRestUpgrade"
},
"host": "management.azure.com",
"schemes": [
Expand Down Expand Up @@ -43,8 +43,8 @@
"operationId": "Workspaces_Get",
"description": "Gets the workspace.",
"responses": {
"default": {
"description": "Error response describing why the operation failed."
"200": {
"description": "Ok-Return"
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions tests-upgrade/basic-response-defaultoperation/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
### AutoRest Configuration
> see https://aka.ms/autorest
``` yaml
require:
- $(this-folder)/../readme.azure.noprofile.md
input-file:
- $(this-folder)/swagger.json

```
Loading

0 comments on commit 66c750d

Please sign in to comment.