|
4 | 4 | "reflect" |
5 | 5 | "testing" |
6 | 6 |
|
| 7 | + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" |
7 | 8 | "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" |
8 | 9 | "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage" |
9 | 10 | "github.com/pkg/errors" |
@@ -371,3 +372,37 @@ func Test_ListAllStorageContainer_Error(t *testing.T) { |
371 | 372 | assert.Nil(t, got) |
372 | 373 | assert.Equal(t, expectedErr, err) |
373 | 374 | } |
| 375 | + |
| 376 | +func Test_ListAllStorageContainer_IgnoredError(t *testing.T) { |
| 377 | + |
| 378 | + account := armstorage.StorageAccount{ |
| 379 | + TrackedResource: armstorage.TrackedResource{ |
| 380 | + Resource: armstorage.Resource{ |
| 381 | + ID: to.StringPtr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/foobar/providers/Microsoft.Storage/storageAccounts/testeliedriftctl"), |
| 382 | + Name: to.StringPtr("testeliedriftctl"), |
| 383 | + }, |
| 384 | + }, |
| 385 | + } |
| 386 | + |
| 387 | + fakeClient := &mockBlobContainerClient{} |
| 388 | + mockPager := &mockBlobContainerListPager{} |
| 389 | + mockPager.On("NextPage", mock.Anything).Return(false).Times(1) |
| 390 | + mockPager.On("Err").Return(runtime.NewResponseError( |
| 391 | + errors.New("{\"error\":{\"code\":\"FeatureNotSupportedForAccount\",\"message\":\"Blob is not supported for the account.\"}}"), |
| 392 | + nil), |
| 393 | + ).Times(1) |
| 394 | + |
| 395 | + fakeClient.On("List", "foobar", "testeliedriftctl", (*armstorage.BlobContainersListOptions)(nil)).Return(mockPager) |
| 396 | + |
| 397 | + s := &storageRepository{ |
| 398 | + blobContainerClient: fakeClient, |
| 399 | + cache: cache.New(0), |
| 400 | + } |
| 401 | + got, err := s.ListAllStorageContainer(&account) |
| 402 | + |
| 403 | + fakeClient.AssertExpectations(t) |
| 404 | + mockPager.AssertExpectations(t) |
| 405 | + |
| 406 | + assert.Empty(t, got) |
| 407 | + assert.Equal(t, nil, err) |
| 408 | +} |
0 commit comments