github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v6@v6.2.0/servicecommunity_live_test.go (about) 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 armnetwork_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/v3/testutil" 18 "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v6" 19 "github.com/stretchr/testify/suite" 20 ) 21 22 type ServiceCommunityTestSuite struct { 23 suite.Suite 24 25 ctx context.Context 26 cred azcore.TokenCredential 27 options *arm.ClientOptions 28 location string 29 resourceGroupName string 30 subscriptionId string 31 } 32 33 func (testsuite *ServiceCommunityTestSuite) SetupSuite() { 34 testutil.StartRecording(testsuite.T(), pathToPackage) 35 36 testsuite.ctx = context.Background() 37 testsuite.cred, testsuite.options = testutil.GetCredAndClientOptions(testsuite.T()) 38 testsuite.location = recording.GetEnvVariable("LOCATION", "westus") 39 testsuite.resourceGroupName = recording.GetEnvVariable("RESOURCE_GROUP_NAME", "scenarioTestTempGroup") 40 testsuite.subscriptionId = recording.GetEnvVariable("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") 41 resourceGroup, _, err := testutil.CreateResourceGroup(testsuite.ctx, testsuite.subscriptionId, testsuite.cred, testsuite.options, testsuite.location) 42 testsuite.Require().NoError(err) 43 testsuite.resourceGroupName = *resourceGroup.Name 44 } 45 46 func (testsuite *ServiceCommunityTestSuite) TearDownSuite() { 47 _, err := testutil.DeleteResourceGroup(testsuite.ctx, testsuite.subscriptionId, testsuite.cred, testsuite.options, testsuite.resourceGroupName) 48 testsuite.Require().NoError(err) 49 testutil.StopRecording(testsuite.T()) 50 } 51 52 func TestServiceCommunityTestSuite(t *testing.T) { 53 suite.Run(t, new(ServiceCommunityTestSuite)) 54 } 55 56 // Microsoft.Network/bgpServiceCommunities 57 func (testsuite *ServiceCommunityTestSuite) TestBgpServiceCommunities() { 58 var err error 59 // From step BgpServiceCommunities_List 60 fmt.Println("Call operation: BgpServiceCommunities_List") 61 bgpServiceCommunitiesClient, err := armnetwork.NewBgpServiceCommunitiesClient(testsuite.subscriptionId, testsuite.cred, testsuite.options) 62 testsuite.Require().NoError(err) 63 bgpServiceCommunitiesClientNewListPager := bgpServiceCommunitiesClient.NewListPager(nil) 64 for bgpServiceCommunitiesClientNewListPager.More() { 65 _, err := bgpServiceCommunitiesClientNewListPager.NextPage(testsuite.ctx) 66 testsuite.Require().NoError(err) 67 break 68 } 69 }