Skip to content

Commit 23abda7

Browse files
authored
doc: add SDK test section to config doc (#19828)
* doc: add SDK test section to config doc * platform resilient * fix duplication
1 parent db55dd6 commit 23abda7

File tree

1 file changed

+47
-2
lines changed

1 file changed

+47
-2
lines changed

documentation/code-gen/configure-go-sdk.md

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Readme Configuration Guide for Azure SDK for Go
22

3-
This file describe how to configure readme files to make it available for Azure SDK for Go code generation.
3+
This doc describe how to configure readme files to make it available for Azure SDK for Go code generation. Also, this doc will introduce how to generate and test Go SDK by yourself.
44

55
## Common Configuration
66

@@ -104,5 +104,50 @@ module-version: 0.1.0
104104

105105
After configure all the readme files, autorest can be used to generate SDK.
106106
~~~
107-
autorest --go --use=@autorest/go@latest --go --track2 --go-sdk-folder=/path/to/azure-sdk-for-go /path/to/azure-rest-api-specs/specification/agrifood/resource-manager/readme.md
107+
autorest --use=@autorest/go@latest --go --track2 --go-sdk-folder=/path/to/azure-sdk-for-go /path/to/azure-rest-api-specs/specification/agrifood/resource-manager/readme.md
108108
~~~
109+
110+
## Test with the generated Go SDK
111+
112+
When you have a generated Go SDK either from swagger PR's automation or from local autorest execution, you could import them locally to test with your own test cases.
113+
114+
For example, here is a [SDK PR](https://github.com/Azure/azure-sdk-for-go/pull/17811) which comes from [swagger PR's automation](https://github.com/Azure/azure-rest-api-specs/pull/19468). You could follow the following steps to test it.
115+
116+
1. Clone the PR code to local
117+
```sh
118+
cd $WORKSPACE
119+
git clone [email protected]:azure-sdk/azure-sdk-for-go.git
120+
cd azure-sdk-for-go
121+
git checkout -t origin/sdkAuto/armcompute
122+
```
123+
124+
2. Copy the generated package to your test project
125+
126+
Shell:
127+
```sh
128+
cp -r sdk/resourcemanager/compute/armcompute $WORKSPACE/test-project
129+
```
130+
131+
PowerShell:
132+
```pwsh
133+
Copy-Item -Path sdk/resourcemanager/compute/armcompute -Destination $WORKSPACE/test-project -Recurse
134+
```
135+
136+
3. Change go.mod in your test project to replace the `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute` module with local code
137+
138+
Shell:
139+
```sh
140+
cd $WORKSPACE/test-project
141+
echo "
142+
replace github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute => ../armcompute" >> go.mod
143+
go mod tidy
144+
```
145+
146+
PowerShell:
147+
```pwsh
148+
cd $WORKSPACE/test-project
149+
Add-Content go.mod "`nreplace github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute => ../armcompute"
150+
go mod tidy
151+
```
152+
153+
4. Now you could reuse or write new tests to test the generated packages.

0 commit comments

Comments
 (0)