From ddfe6e9ecb2616db2a3864bb910a937a33d5bfc1 Mon Sep 17 00:00:00 2001 From: Elie Date: Fri, 17 Sep 2021 11:27:24 +0200 Subject: [PATCH] Fix azure may hide some errors --- pkg/remote/azurerm/repository/storage.go | 8 ++++++++ pkg/remote/azurerm/repository/storage_test.go | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/remote/azurerm/repository/storage.go b/pkg/remote/azurerm/repository/storage.go index ba886530..3f7e2131 100644 --- a/pkg/remote/azurerm/repository/storage.go +++ b/pkg/remote/azurerm/repository/storage.go @@ -63,6 +63,10 @@ func (s *storageRepository) ListAllStorageAccount() ([]*armstorage.StorageAccoun results = append(results, resp.StorageAccountListResult.Value...) } + if err := pager.Err(); err != nil { + return nil, err + } + s.cache.Put("ListAllStorageAccount", results) return results, nil @@ -92,6 +96,10 @@ func (s *storageRepository) ListAllStorageContainer(account *armstorage.StorageA } } + if err := pager.Err(); err != nil { + return nil, err + } + s.cache.Put(cacheKey, results) return results, nil diff --git a/pkg/remote/azurerm/repository/storage_test.go b/pkg/remote/azurerm/repository/storage_test.go index 12437f88..a723d1ca 100644 --- a/pkg/remote/azurerm/repository/storage_test.go +++ b/pkg/remote/azurerm/repository/storage_test.go @@ -50,7 +50,7 @@ func Test_ListAllStorageAccount_MultiplesResults(t *testing.T) { fakeClient := &mockStorageAccountClient{} mockPager := &azure.MockStorageAccountPager{} - mockPager.On("Err").Return(nil).Times(2) + mockPager.On("Err").Return(nil).Times(3) mockPager.On("NextPage", mock.Anything).Return(true).Times(2) mockPager.On("NextPage", mock.Anything).Return(false).Times(1) mockPager.On("PageResponse").Return(armstorage.StorageAccountListResultResponse{ @@ -207,7 +207,7 @@ func Test_ListAllStorageContainer_MultiplesResults(t *testing.T) { fakeClient := &mockBlobContainerClient{} mockPager := &azure.MockListContainerItemPager{} - mockPager.On("Err").Return(nil).Times(2) + mockPager.On("Err").Return(nil).Times(3) mockPager.On("NextPage", mock.Anything).Return(true).Times(2) mockPager.On("NextPage", mock.Anything).Return(false).Times(1) mockPager.On("PageResponse").Return(armstorage.ListContainerItemsResponse{