From 8ec7b3f7bfbd82b5063831348231d7fe5b333ad7 Mon Sep 17 00:00:00 2001
From: Stephane Selim <stephane.selim@swisscom.com>
Date: Tue, 13 Aug 2024 15:22:56 +0200
Subject: [PATCH] remove redundant tests

Signed-off-by: Stephane Selim <stephane.selim@swisscom.com>
---
 .../cloudwatchlogs/resourcepolicy/setup.go    | 25 +-----
 .../resourcepolicy/setup_test.go              | 89 -------------------
 2 files changed, 3 insertions(+), 111 deletions(-)

diff --git a/pkg/controller/cloudwatchlogs/resourcepolicy/setup.go b/pkg/controller/cloudwatchlogs/resourcepolicy/setup.go
index 65b52e589b..2d5350dd7b 100644
--- a/pkg/controller/cloudwatchlogs/resourcepolicy/setup.go
+++ b/pkg/controller/cloudwatchlogs/resourcepolicy/setup.go
@@ -14,7 +14,6 @@ import (
 	"github.com/crossplane/crossplane-runtime/pkg/resource"
 	"github.com/pkg/errors"
 	ctrl "sigs.k8s.io/controller-runtime"
-	"sigs.k8s.io/controller-runtime/pkg/client"
 
 	svcapitypes "github.com/crossplane-contrib/provider-aws/apis/cloudwatchlogs/v1alpha1"
 	"github.com/crossplane-contrib/provider-aws/apis/v1alpha1"
@@ -35,7 +34,7 @@ func SetupResourcePolicy(mgr ctrl.Manager, o controller.Options) error {
 
 	opts := []option{
 		func(e *external) {
-			c := &custom{client: e.client, kube: e.kube, external: e}
+			c := &custom{client: e.client}
 			e.filterList = filterList
 			e.preCreate = preCreate
 			e.preDelete = preDelete
@@ -60,9 +59,7 @@ func SetupResourcePolicy(mgr ctrl.Manager, o controller.Options) error {
 }
 
 type custom struct {
-	kube     client.Client
-	client   svcsdkapi.CloudWatchLogsAPI
-	external *external
+	client svcsdkapi.CloudWatchLogsAPI
 }
 
 func preCreate(_ context.Context, cr *svcapitypes.ResourcePolicy, obj *svcsdk.PutResourcePolicyInput) error {
@@ -84,14 +81,6 @@ func postObserve(_ context.Context, cr *svcapitypes.ResourcePolicy, _ *svcsdk.De
 }
 
 func isUpToDate(_ context.Context, cr *svcapitypes.ResourcePolicy, obj *svcsdk.DescribeResourcePoliciesOutput) (bool, string, error) {
-	if obj == nil || len(obj.ResourcePolicies) == 0 {
-		return false, "", nil
-	}
-
-	if cr == nil || cr.Spec.ForProvider.PolicyDocument == nil {
-		return false, "", nil
-	}
-
 	// Check if the policy exists
 	for _, policy := range obj.ResourcePolicies {
 		if policy.PolicyName != nil && *policy.PolicyName == meta.GetExternalName(cr) {
@@ -103,16 +92,8 @@ func isUpToDate(_ context.Context, cr *svcapitypes.ResourcePolicy, obj *svcsdk.D
 }
 
 func filterList(cr *svcapitypes.ResourcePolicy, obj *svcsdk.DescribeResourcePoliciesOutput) *svcsdk.DescribeResourcePoliciesOutput {
-	resp := &svcsdk.DescribeResourcePoliciesOutput{}
-	if obj == nil || len(obj.ResourcePolicies) == 0 {
-		return resp
-	}
-
-	if cr == nil {
-		return resp
-	}
-
 	resourcePolicyIdentifier := pointer.ToOrNilIfZeroValue(meta.GetExternalName(cr))
+	resp := &svcsdk.DescribeResourcePoliciesOutput{}
 
 	for _, resourcePolicy := range obj.ResourcePolicies {
 		if pointer.StringValue(resourcePolicy.PolicyName) == pointer.StringValue(resourcePolicyIdentifier) {
diff --git a/pkg/controller/cloudwatchlogs/resourcepolicy/setup_test.go b/pkg/controller/cloudwatchlogs/resourcepolicy/setup_test.go
index dc30873366..a09b790992 100644
--- a/pkg/controller/cloudwatchlogs/resourcepolicy/setup_test.go
+++ b/pkg/controller/cloudwatchlogs/resourcepolicy/setup_test.go
@@ -194,55 +194,6 @@ func TestIsUpToDate(t *testing.T) {
 				err:    nil,
 			},
 		},
-		"ResourcePolicyNotFoundNilDescribeResourcePoliciesOutput": {
-			args: args{
-				describeResourcePoliciesOutput: nil,
-				resourcePolicy: &svcapitypes.ResourcePolicy{
-					ObjectMeta: metav1.ObjectMeta{
-						Name: policyName,
-						Annotations: map[string]string{
-							meta.AnnotationKeyExternalName: policyName,
-						},
-					},
-					Spec: svcapitypes.ResourcePolicySpec{
-						ForProvider: svcapitypes.ResourcePolicyParameters{
-							PolicyDocument: aws.String(testPolicyDocument),
-						},
-					},
-				},
-			},
-			want: want{
-				result: false,
-				err:    nil,
-			},
-		},
-		"ResourcePolicyNotFoundNilResourcePolicy": {
-			args: args{
-				describeResourcePoliciesOutput: &svcsdk.DescribeResourcePoliciesOutput{
-					ResourcePolicies: []*svcsdk.ResourcePolicy{
-						{
-							PolicyName:     aws.String(policyName),
-							PolicyDocument: aws.String(testPolicyDocument),
-						},
-					},
-				},
-				resourcePolicy: nil,
-			},
-			want: want{
-				result: false,
-				err:    nil,
-			},
-		},
-		"ResourcePolicyNotFoundNilResourcePolicyAndDescribeResourcePoliciesOutput": {
-			args: args{
-				describeResourcePoliciesOutput: nil,
-				resourcePolicy:                 nil,
-			},
-			want: want{
-				result: false,
-				err:    nil,
-			},
-		},
 	}
 
 	for name, tc := range cases {
@@ -339,46 +290,6 @@ func TestFilterList(t *testing.T) {
 				resp: &svcsdk.DescribeResourcePoliciesOutput{},
 			},
 		},
-		"ResourcePolicyNotFoundNilDescribeResourcePoliciesOutput": {
-			args: args{
-				describeResourcePoliciesOutput: nil,
-				resourcePolicy: &svcapitypes.ResourcePolicy{
-					ObjectMeta: metav1.ObjectMeta{
-						Name: policyName,
-						Annotations: map[string]string{
-							meta.AnnotationKeyExternalName: policyName,
-						},
-					},
-				},
-			},
-			want: want{
-				resp: &svcsdk.DescribeResourcePoliciesOutput{},
-			},
-		},
-		"ResourcePolicyNotFoundNilResourcePolicy": {
-			args: args{
-				describeResourcePoliciesOutput: &svcsdk.DescribeResourcePoliciesOutput{
-					ResourcePolicies: []*svcsdk.ResourcePolicy{
-						{
-							PolicyName: aws.String(policyName),
-						},
-					},
-				},
-				resourcePolicy: nil,
-			},
-			want: want{
-				resp: &svcsdk.DescribeResourcePoliciesOutput{},
-			},
-		},
-		"ResourcePolicyNotFoundNilResourcePolicyAndDescribeResourcePoliciesOutput": {
-			args: args{
-				describeResourcePoliciesOutput: nil,
-				resourcePolicy:                 nil,
-			},
-			want: want{
-				resp: &svcsdk.DescribeResourcePoliciesOutput{},
-			},
-		},
 	}
 
 	for name, tc := range cases {