Fix unit tests after vendor upgrades

This commit is contained in:
Pengfei Ni 2021-04-22 09:28:46 +00:00
parent bee44da7a2
commit b793209080
3 changed files with 7 additions and 3 deletions

View File

@ -380,8 +380,10 @@ func TestListWithNextPage(t *testing.T) {
resourceID := "/subscriptions/subscriptionID/resourceGroups/rg/providers/Microsoft.ContainerService/managedClusters"
armClient := mockarmclient.NewMockInterface(ctrl)
mcList := []containerservice.ManagedCluster{getTestManagedCluster("cluster"), getTestManagedCluster("cluster1"), getTestManagedCluster("cluster2")}
responseBody, err := json.Marshal(containerservice.ManagedClusterListResult{Value: &mcList, NextLink: to.StringPtr("nextLink")})
// ManagedClusterListResult.MarshalJson() doesn't include "nextLink" in its result, hence responseBody is composed manually below.
responseBody, err := json.Marshal(map[string]interface{}{"value": mcList, "nextLink": "nextLink"})
assert.NoError(t, err)
pagedResponse, err := json.Marshal(containerservice.ManagedClusterListResult{Value: &mcList})
assert.NoError(t, err)
armClient.EXPECT().PrepareGetRequest(gomock.Any(), gomock.Any()).Return(&http.Request{}, nil)

View File

@ -378,7 +378,8 @@ func TestListWithNextPage(t *testing.T) {
resourceID := "/subscriptions/subscriptionID/resourceGroups/rg/providers/Microsoft.Resources/deployments"
armClient := mockarmclient.NewMockInterface(ctrl)
dpList := []resources.DeploymentExtended{getTestDeploymentExtended("dep"), getTestDeploymentExtended("dep1"), getTestDeploymentExtended("dep2")}
partialResponse, err := json.Marshal(resources.DeploymentListResult{Value: &dpList, NextLink: to.StringPtr("nextLink")})
// DeploymentListResult.MarshalJson() doesn't include "nextLink" in its result, hence partialResponse is composed manually below.
partialResponse, err := json.Marshal(map[string]interface{}{"value": dpList, "nextLink": "nextLink"})
assert.NoError(t, err)
pagedResponse, err := json.Marshal(resources.DeploymentListResult{Value: &dpList})
assert.NoError(t, err)

View File

@ -172,7 +172,8 @@ func TestListWithNextPage(t *testing.T) {
resourceID := "/subscriptions/subscriptionID/resourceGroups/rg/providers/Microsoft.Network/loadBalancers"
armClient := mockarmclient.NewMockInterface(ctrl)
lbList := []network.LoadBalancer{getTestLoadBalancer("lb1"), getTestLoadBalancer("lb2"), getTestLoadBalancer("lb3")}
partialResponse, err := json.Marshal(network.LoadBalancerListResult{Value: &lbList, NextLink: to.StringPtr("nextLink")})
// LoadBalancerListResult.MarshalJson() doesn't include "nextLink" in its result, hence partialResponse is composed manually below.
partialResponse, err := json.Marshal(map[string]interface{}{"value": lbList, "nextLink": "nextLink"})
assert.NoError(t, err)
pagedResponse, err := json.Marshal(network.LoadBalancerListResult{Value: &lbList})
assert.NoError(t, err)