From 53967b20a74f6100d6ea8c9f0ba6783778e7d94d Mon Sep 17 00:00:00 2001 From: Erik Kristensen Date: Mon, 22 Apr 2024 19:02:26 -0600 Subject: [PATCH] chore: resolve golangci-lint issues --- resources/elasticache-memcacheclusters.go | 5 +++-- .../elasticache-memcacheclusters_mock_test.go | 17 ++++++++++------- resources/elasticache-subnetgroups.go | 7 ++++--- resources/elasticache-subnetgroups_mock_test.go | 11 +++++++---- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/resources/elasticache-memcacheclusters.go b/resources/elasticache-memcacheclusters.go index f72fc8ec..ee4c56e8 100644 --- a/resources/elasticache-memcacheclusters.go +++ b/resources/elasticache-memcacheclusters.go @@ -2,15 +2,16 @@ package resources import ( "context" - "github.com/aws/aws-sdk-go/service/elasticache/elasticacheiface" - "github.com/ekristen/libnuke/pkg/types" + "github.com/sirupsen/logrus" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/elasticache" + "github.com/aws/aws-sdk-go/service/elasticache/elasticacheiface" "github.com/ekristen/libnuke/pkg/registry" "github.com/ekristen/libnuke/pkg/resource" + "github.com/ekristen/libnuke/pkg/types" "github.com/ekristen/aws-nuke/pkg/nuke" ) diff --git a/resources/elasticache-memcacheclusters_mock_test.go b/resources/elasticache-memcacheclusters_mock_test.go index e9685f31..bb963c19 100644 --- a/resources/elasticache-memcacheclusters_mock_test.go +++ b/resources/elasticache-memcacheclusters_mock_test.go @@ -1,13 +1,17 @@ package resources import ( + "context" + "testing" + + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/assert" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/elasticache" + "github.com/ekristen/aws-nuke/mocks/mock_elasticacheiface" "github.com/ekristen/aws-nuke/pkg/nuke" - "github.com/golang/mock/gomock" - "github.com/stretchr/testify/assert" - "testing" ) func Test_Mock_ElastiCache_CacheCluster_Remove(t *testing.T) { @@ -26,7 +30,7 @@ func Test_Mock_ElastiCache_CacheCluster_Remove(t *testing.T) { CacheClusterId: aws.String("foobar"), }).Return(&elasticache.DeleteCacheClusterOutput{}, nil) - err := cacheCluster.Remove(nil) + err := cacheCluster.Remove(context.TODO()) a.Nil(err) } @@ -54,7 +58,7 @@ func Test_Mock_ElastiCache_CacheCluster_List_NoTags(t *testing.T) { ResourceName: aws.String("foobar"), }).Return(&elasticache.TagListMessage{}, nil) - resources, err := cacheClusterLister.List(nil, &nuke.ListerOpts{}) + resources, err := cacheClusterLister.List(context.TODO(), &nuke.ListerOpts{}) a.Nil(err) a.Len(resources, 1) @@ -96,7 +100,7 @@ func Test_Mock_ElastiCache_CacheCluster_List_WithTags(t *testing.T) { }, }, nil) - resources, err := cacheClusterLister.List(nil, &nuke.ListerOpts{}) + resources, err := cacheClusterLister.List(context.TODO(), &nuke.ListerOpts{}) a.Nil(err) a.Len(resources, 1) @@ -105,5 +109,4 @@ func Test_Mock_ElastiCache_CacheCluster_List_WithTags(t *testing.T) { a.Equal("foobar", resource.String()) a.Equal("foobar", resource.Properties().Get("tag:Name")) a.Equal("test", resource.Properties().Get("tag:aws-nuke")) - } diff --git a/resources/elasticache-subnetgroups.go b/resources/elasticache-subnetgroups.go index 4ded8ea5..f2a92b73 100644 --- a/resources/elasticache-subnetgroups.go +++ b/resources/elasticache-subnetgroups.go @@ -3,16 +3,17 @@ package resources import ( "context" "fmt" - "github.com/aws/aws-sdk-go/service/elasticache/elasticacheiface" - "github.com/ekristen/libnuke/pkg/types" - "github.com/sirupsen/logrus" "strings" + "github.com/sirupsen/logrus" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/elasticache" + "github.com/aws/aws-sdk-go/service/elasticache/elasticacheiface" "github.com/ekristen/libnuke/pkg/registry" "github.com/ekristen/libnuke/pkg/resource" + "github.com/ekristen/libnuke/pkg/types" "github.com/ekristen/aws-nuke/pkg/nuke" ) diff --git a/resources/elasticache-subnetgroups_mock_test.go b/resources/elasticache-subnetgroups_mock_test.go index 039773f7..d02d5dbf 100644 --- a/resources/elasticache-subnetgroups_mock_test.go +++ b/resources/elasticache-subnetgroups_mock_test.go @@ -1,6 +1,7 @@ package resources import ( + "context" "testing" "github.com/golang/mock/gomock" @@ -25,9 +26,11 @@ func Test_Mock_ElastiCache_SubnetGroup_Remove(t *testing.T) { name: aws.String("foobar"), } - mockElastiCache.EXPECT().DeleteCacheSubnetGroup(gomock.Any()).Return(&elasticache.DeleteCacheSubnetGroupOutput{}, nil) + mockElastiCache.EXPECT().DeleteCacheSubnetGroup(&elasticache.DeleteCacheSubnetGroupInput{ + CacheSubnetGroupName: aws.String("foobar"), + }).Return(&elasticache.DeleteCacheSubnetGroupOutput{}, nil) - err := subnetGroup.Remove(nil) + err := subnetGroup.Remove(context.TODO()) a.Nil(err) a.Equal("foobar", *subnetGroup.name) } @@ -55,7 +58,7 @@ func Test_Mock_ElastiCache_SubnetGroup_List_NoTags(t *testing.T) { ResourceName: aws.String("foobar"), }).Return(&elasticache.TagListMessage{}, nil) - resources, err := subnetGroupsLister.List(nil, &nuke.ListerOpts{}) + resources, err := subnetGroupsLister.List(context.TODO(), &nuke.ListerOpts{}) a.Nil(err) a.Len(resources, 1) @@ -99,7 +102,7 @@ func Test_Mock_ElastiCache_SubnetGroup_List_WithTags(t *testing.T) { }, }, nil) - resources, err := subnetGroupsLister.List(nil, &nuke.ListerOpts{}) + resources, err := subnetGroupsLister.List(context.TODO(), &nuke.ListerOpts{}) a.Nil(err) a.Len(resources, 1)