Skip to content

Commit 0cf3f2c

Browse files
authored
sdk/resourcemanager/quota/armquota live test (Azure#22082)
1 parent 8db9a88 commit 0cf3f2c

File tree

4 files changed

+168
-1
lines changed

4 files changed

+168
-1
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"AssetsRepo": "Azure/azure-sdk-assets",
3+
"AssetsRepoPrefixPath": "go",
4+
"TagPrefix": "go/resourcemanager/quota/armquota",
5+
"Tag": "go/resourcemanager/quota/armquota_b25f4c8e26"
6+
}

sdk/resourcemanager/quota/armquota/go.mod

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,25 @@ go 1.18
55
require (
66
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0
77
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0
8+
github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0
9+
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2 v2.0.0
10+
github.com/stretchr/testify v1.8.4
811
)
912

1013
require (
11-
github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 // indirect
14+
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.1.1 // indirect
1215
github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect
16+
github.com/davecgh/go-spew v1.1.1 // indirect
17+
github.com/dnaeon/go-vcr v1.2.0 // indirect
1318
github.com/golang-jwt/jwt/v5 v5.0.0 // indirect
1419
github.com/google/uuid v1.3.1 // indirect
1520
github.com/kylelemons/godebug v1.1.0 // indirect
1621
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
22+
github.com/pmezard/go-difflib v1.0.0 // indirect
1723
golang.org/x/crypto v0.14.0 // indirect
1824
golang.org/x/net v0.17.0 // indirect
1925
golang.org/x/sys v0.13.0 // indirect
2026
golang.org/x/text v0.13.0 // indirect
27+
gopkg.in/yaml.v2 v2.4.0 // indirect
28+
gopkg.in/yaml.v3 v3.0.1 // indirect
2129
)

sdk/resourcemanager/quota/armquota/go.sum

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,31 @@ github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 h1:BMAjVKJM0U/CYF27gA0ZM
44
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0/go.mod h1:1fXstnBMas5kzG+S3q8UoJcmyU6nUeunJcMDHcRYHhs=
55
github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 h1:d81/ng9rET2YqdVkVwkb6EXeRrLJIwyGnJcAlAWKwhs=
66
github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI=
7+
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.1.2 h1:mLY+pNLjCUeKhgnAJWAKhEUQM+RJQo2H1fuGSw1Ky1E=
8+
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2 v2.0.0 h1:PTFGRSlMKCQelWwxUyYVEUqseBJVemLyqWJjvMyt0do=
9+
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2 v2.0.0/go.mod h1:LRr2FzBTQlONPPa5HREE5+RjSCTXl7BwOvYOaWTqCaI=
10+
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups v1.0.0 h1:pPvTJ1dY0sA35JOeFq6TsY2xj6Z85Yo23Pj4wCCvu4o=
11+
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.1.1 h1:7CBQ+Ei8SP2c6ydQTGCCrS35bDxgTMfoP2miAwK++OU=
12+
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.1.1/go.mod h1:c/wcGeGx5FUPbM/JltUYHZcKmigwyVLJlDq+4HdtXaw=
713
github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 h1:WpB/QDNLpMw72xHJc34BNNykqSOeEJDAWkhf0u12/Jk=
814
github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI=
915
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
16+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
1017
github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI=
18+
github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ=
1119
github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE=
1220
github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
1321
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
1422
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
1523
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
1624
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
25+
github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8=
1726
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU=
1827
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI=
1928
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
29+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
2030
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
31+
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
2132
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
2233
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
2334
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
@@ -27,5 +38,10 @@ golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
2738
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
2839
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
2940
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
41+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
42+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
43+
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
3044
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
45+
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
3146
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
47+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
//go:build go1.18
2+
// +build go1.18
3+
4+
// Copyright (c) Microsoft Corporation. All rights reserved.
5+
// Licensed under the MIT License. See License.txt in the project root for license information.
6+
7+
package armquota_test
8+
9+
import (
10+
"context"
11+
"fmt"
12+
"testing"
13+
14+
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
15+
"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
16+
"github.com/Azure/azure-sdk-for-go/sdk/internal/recording"
17+
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2/testutil"
18+
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/quota/armquota"
19+
"github.com/stretchr/testify/suite"
20+
)
21+
22+
type QuotaTestSuite struct {
23+
suite.Suite
24+
25+
ctx context.Context
26+
cred azcore.TokenCredential
27+
options *arm.ClientOptions
28+
armEndpoint string
29+
location string
30+
resourceGroupName string
31+
subscriptionId string
32+
}
33+
34+
func (testsuite *QuotaTestSuite) SetupSuite() {
35+
testutil.StartRecording(testsuite.T(), "sdk/resourcemanager/quota/armquota/testdata")
36+
37+
testsuite.ctx = context.Background()
38+
testsuite.cred, testsuite.options = testutil.GetCredAndClientOptions(testsuite.T())
39+
testsuite.armEndpoint = "https://management.azure.com"
40+
testsuite.location = recording.GetEnvVariable("LOCATION", "eastus")
41+
testsuite.resourceGroupName = recording.GetEnvVariable("RESOURCE_GROUP_NAME", "scenarioTestTempGroup")
42+
testsuite.subscriptionId = recording.GetEnvVariable("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000")
43+
resourceGroup, _, err := testutil.CreateResourceGroup(testsuite.ctx, testsuite.subscriptionId, testsuite.cred, testsuite.options, testsuite.location)
44+
testsuite.Require().NoError(err)
45+
testsuite.resourceGroupName = *resourceGroup.Name
46+
}
47+
48+
func (testsuite *QuotaTestSuite) TearDownSuite() {
49+
_, err := testutil.DeleteResourceGroup(testsuite.ctx, testsuite.subscriptionId, testsuite.cred, testsuite.options, testsuite.resourceGroupName)
50+
testsuite.Require().NoError(err)
51+
testutil.StopRecording(testsuite.T())
52+
}
53+
54+
func TestQuotaTestSuite(t *testing.T) {
55+
suite.Run(t, new(QuotaTestSuite))
56+
}
57+
58+
// Microsoft.Quota/quotas/{resourceName}
59+
func (testsuite *QuotaTestSuite) TestQuota() {
60+
var id string
61+
var err error
62+
63+
// From step Quota_List
64+
fmt.Println("Call operation: Quota_List")
65+
client, err := armquota.NewClient(testsuite.cred, testsuite.options)
66+
testsuite.Require().NoError(err)
67+
clientNewListPager := client.NewListPager("subscriptions/"+testsuite.subscriptionId+"/providers/Microsoft.Network/locations/eastus", nil)
68+
for clientNewListPager.More() {
69+
_, err := clientNewListPager.NextPage(testsuite.ctx)
70+
testsuite.Require().NoError(err)
71+
break
72+
}
73+
74+
// From step Quota_Get
75+
fmt.Println("Call operation: Quota_Get")
76+
_, err = client.Get(testsuite.ctx, "MinPublicIpInterNetworkPrefixLength", "subscriptions/"+testsuite.subscriptionId+"/providers/Microsoft.Network/locations/eastus", nil)
77+
testsuite.Require().NoError(err)
78+
79+
// From step QuotaRequestStatus_List
80+
fmt.Println("Call operation: QuotaRequestStatus_List")
81+
requestStatusClient, err := armquota.NewRequestStatusClient(testsuite.cred, testsuite.options)
82+
testsuite.Require().NoError(err)
83+
requestStatusClientNewListPager := requestStatusClient.NewListPager("subscriptions/"+testsuite.subscriptionId+"/providers/Microsoft.Network/locations/eastus", &armquota.RequestStatusClientListOptions{Filter: nil,
84+
Top: nil,
85+
Skiptoken: nil,
86+
})
87+
for requestStatusClientNewListPager.More() {
88+
nextResult, err := requestStatusClientNewListPager.NextPage(testsuite.ctx)
89+
testsuite.Require().NoError(err)
90+
91+
id = *nextResult.Value[0].Name
92+
break
93+
}
94+
95+
// From step QuotaRequestStatus_Get
96+
fmt.Println("Call operation: QuotaRequestStatus_Get")
97+
_, err = requestStatusClient.Get(testsuite.ctx, id, "subscriptions/"+testsuite.subscriptionId+"/providers/Microsoft.Network/locations/eastus", nil)
98+
testsuite.Require().NoError(err)
99+
}
100+
101+
// Microsoft.Quota/operations
102+
func (testsuite *QuotaTestSuite) TestQuotaOperation() {
103+
var err error
104+
// From step QuotaOperation_List
105+
fmt.Println("Call operation: QuotaOperation_List")
106+
operationClient, err := armquota.NewOperationClient(testsuite.cred, testsuite.options)
107+
testsuite.Require().NoError(err)
108+
operationClientNewListPager := operationClient.NewListPager(nil)
109+
for operationClientNewListPager.More() {
110+
_, err := operationClientNewListPager.NextPage(testsuite.ctx)
111+
testsuite.Require().NoError(err)
112+
break
113+
}
114+
}
115+
116+
// Microsoft.Quota/usages/{resourceName}
117+
func (testsuite *QuotaTestSuite) TestUsages() {
118+
var resourceName string
119+
var err error
120+
// From step Usages_List
121+
fmt.Println("Call operation: Usages_List")
122+
usagesClient, err := armquota.NewUsagesClient(testsuite.cred, testsuite.options)
123+
testsuite.Require().NoError(err)
124+
usagesClientNewListPager := usagesClient.NewListPager("subscriptions/"+testsuite.subscriptionId+"/providers/Microsoft.Network/locations/eastus", nil)
125+
for usagesClientNewListPager.More() {
126+
nextResult, err := usagesClientNewListPager.NextPage(testsuite.ctx)
127+
testsuite.Require().NoError(err)
128+
129+
resourceName = *nextResult.Value[0].Name
130+
break
131+
}
132+
133+
// From step Usages_Get
134+
fmt.Println("Call operation: Usages_Get")
135+
_, err = usagesClient.Get(testsuite.ctx, resourceName, "subscriptions/"+testsuite.subscriptionId+"/providers/Microsoft.Network/locations/eastus", nil)
136+
testsuite.Require().NoError(err)
137+
}

0 commit comments

Comments
 (0)