diff --git a/pkg/remote/aws/repository/elbv2_repository_test.go b/pkg/remote/aws/repository/elbv2_repository_test.go index 6f8865ac..56ca547e 100644 --- a/pkg/remote/aws/repository/elbv2_repository_test.go +++ b/pkg/remote/aws/repository/elbv2_repository_test.go @@ -15,7 +15,7 @@ import ( "github.com/stretchr/testify/assert" ) -func Test_ELBv2Repository_ListAllLoadBalancers(t *testing.T) { +func Test_ELBV2Repository_ListAllLoadBalancers(t *testing.T) { dummyError := errors.New("dummy error") tests := []struct { diff --git a/pkg/remote/elbv2_scanner_test.go b/pkg/remote/aws_elbv2_scanner_test.go similarity index 87% rename from pkg/remote/elbv2_scanner_test.go rename to pkg/remote/aws_elbv2_scanner_test.go index 6730419c..7f2d2605 100644 --- a/pkg/remote/elbv2_scanner_test.go +++ b/pkg/remote/aws_elbv2_scanner_test.go @@ -23,6 +23,8 @@ import ( ) func TestLoadBalancer(t *testing.T) { + dummyError := errors.New("dummy error") + tests := []struct { test string mocks func(*repository.MockELBV2Repository, *mocks.AlerterInterface) @@ -55,7 +57,7 @@ func TestLoadBalancer(t *testing.T) { }, }, { - test: "cannot list load balancers", + test: "cannot list load balancers (403)", mocks: func(repository *repository.MockELBV2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllLoadBalancers").Return(nil, awsError) @@ -66,6 +68,16 @@ func TestLoadBalancer(t *testing.T) { assert.Len(t, got, 0) }, }, + { + test: "cannot list load balancers (dummy error)", + mocks: func(repository *repository.MockELBV2Repository, alerter *mocks.AlerterInterface) { + repository.On("ListAllLoadBalancers").Return(nil, dummyError) + }, + assertExpected: func(t *testing.T, got []*resource.Resource) { + assert.Len(t, got, 0) + }, + wantErr: remoteerr.NewResourceScanningError(dummyError, resourceaws.AwsLoadBalancerResourceType, ""), + }, } schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") diff --git a/pkg/remote/test/aws_lb_list/aws_lb-arn_aws_elasticloadbalancing_us-east-1_533948124879_loadbalancer_app_test-lb-tf_35be57d467ff22b9.res.golden.json b/pkg/remote/test/aws_lb_list/aws_lb-arn_aws_elasticloadbalancing_us-east-1_533948124879_loadbalancer_app_test-lb-tf_35be57d467ff22b9.res.golden.json deleted file mode 100755 index 4541a04c..00000000 --- a/pkg/remote/test/aws_lb_list/aws_lb-arn_aws_elasticloadbalancing_us-east-1_533948124879_loadbalancer_app_test-lb-tf_35be57d467ff22b9.res.golden.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "Typ": "WyJvYmplY3QiLHsiYWNjZXNzX2xvZ3MiOlsibGlzdCIsWyJvYmplY3QiLHsiYnVja2V0Ijoic3RyaW5nIiwiZW5hYmxlZCI6ImJvb2wiLCJwcmVmaXgiOiJzdHJpbmcifV1dLCJhcm4iOiJzdHJpbmciLCJhcm5fc3VmZml4Ijoic3RyaW5nIiwiY3VzdG9tZXJfb3duZWRfaXB2NF9wb29sIjoic3RyaW5nIiwiZG5zX25hbWUiOiJzdHJpbmciLCJkcm9wX2ludmFsaWRfaGVhZGVyX2ZpZWxkcyI6ImJvb2wiLCJlbmFibGVfY3Jvc3Nfem9uZV9sb2FkX2JhbGFuY2luZyI6ImJvb2wiLCJlbmFibGVfZGVsZXRpb25fcHJvdGVjdGlvbiI6ImJvb2wiLCJlbmFibGVfaHR0cDIiOiJib29sIiwiaWQiOiJzdHJpbmciLCJpZGxlX3RpbWVvdXQiOiJudW1iZXIiLCJpbnRlcm5hbCI6ImJvb2wiLCJpcF9hZGRyZXNzX3R5cGUiOiJzdHJpbmciLCJsb2FkX2JhbGFuY2VyX3R5cGUiOiJzdHJpbmciLCJuYW1lIjoic3RyaW5nIiwibmFtZV9wcmVmaXgiOiJzdHJpbmciLCJzZWN1cml0eV9ncm91cHMiOlsic2V0Iiwic3RyaW5nIl0sInN1Ym5ldF9tYXBwaW5nIjpbInNldCIsWyJvYmplY3QiLHsiYWxsb2NhdGlvbl9pZCI6InN0cmluZyIsIm91dHBv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91dCI6NjAsImludGVybmFsIjpmYWxzZSwiaXBfYWRkcmVzc190eXBlIjoiaXB2NCIsImxvYWRfYmFsYW5jZXJfdHlwZSI6ImFwcGxpY2F0aW9uIiwibmFtZSI6InRlc3QtbGItdGYiLCJuYW1lX3ByZWZpeCI6bnVsbCwic2VjdXJpdHlfZ3JvdXBzIjpbInNnLTA2ZmVjZmFhNzExZTY1YjZjIl0sInN1Ym5ldF9tYXBwaW5nIjpbeyJhbGxvY2F0aW9uX2lkIjoiIiwib3V0cG9zdF9pZCI6IiIsInByaXZhdGVfaXB2NF9hZGRyZXNzIjoiIiwic3VibmV0X2lkIjoic3VibmV0LTAwMzcxMzUxM2QzN2MwOTA1In0seyJhbGxvY2F0aW9uX2lkIjoiIiwib3V0cG9zdF9pZCI6IiIsInByaXZhdGVfaXB2NF9hZGRyZXNzIjoiIiwic3VibmV0X2lkIjoic3VibmV0LTA2MzE2MmYyMzA1M2ViZmRkIn1dLCJzdWJuZXRzIjpbInN1Ym5ldC0wMDM3MTM1MTNkMzdjMDkwNSIsInN1Ym5ldC0wNjMxNjJmMjMwNTNlYmZkZCJdLCJ0YWdzIjp7IkVudmlyb25tZW50IjoiZGV2In0sInRpbWVvdXRzIjp7ImNyZWF0ZSI6bnVsbCwiZGVsZXRlIjpudWxsLCJ1cGRhdGUiOm51bGx9LCJ2cGNfaWQiOiJ2cGMtMGFlMWYxMzhhMDk3NDllZjEiLCJ6b25lX2lkIjoiWjM1U1hET1RSUTdYN0sifQ==", - "Err": null -} \ No newline at end of file diff --git a/pkg/remote/test/aws_lb_list/results.golden.json b/pkg/remote/test/aws_lb_list/results.golden.json deleted file mode 100755 index b85ea368..00000000 --- a/pkg/remote/test/aws_lb_list/results.golden.json +++ /dev/null @@ -1,27 +0,0 @@ -[ - { - "access_logs": null, - "arn": null, - "arn_suffix": null, - "customer_owned_ipv4_pool": null, - "dns_name": null, - "drop_invalid_header_fields": null, - "enable_cross_zone_load_balancing": null, - "enable_deletion_protection": null, - "enable_http2": null, - "id": null, - "idle_timeout": null, - "internal": null, - "ip_address_type": null, - "load_balancer_type": null, - "name": "acc-test-lb-tf", - "name_prefix": null, - "security_groups": null, - "subnet_mapping": null, - "subnets": null, - "tags": null, - "timeouts": null, - "vpc_id": null, - "zone_id": null - } -] \ No newline at end of file