From 588613962526797ef65ff7b50bf3e143c5704607 Mon Sep 17 00:00:00 2001 From: Aaron Miller <1521726+aaroniscode@users.noreply.github.com> Date: Thu, 23 May 2024 16:23:02 +0000 Subject: [PATCH] address more feedback --- pkg/aws/services/tagging.go | 2 +- pkg/aws/services/tagging_test.go | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/pkg/aws/services/tagging.go b/pkg/aws/services/tagging.go index e798427f..22c59991 100644 --- a/pkg/aws/services/tagging.go +++ b/pkg/aws/services/tagging.go @@ -144,7 +144,7 @@ func containsTags(source, check Tags) bool { return false } } - return true + return len(check) != 0 } func convertTags(tags []*taggingapi.Tag) Tags { diff --git a/pkg/aws/services/tagging_test.go b/pkg/aws/services/tagging_test.go index e809eb3e..47c88617 100644 --- a/pkg/aws/services/tagging_test.go +++ b/pkg/aws/services/tagging_test.go @@ -58,11 +58,11 @@ func TestContainsTags(t *testing.T) { "Key2": aws.String("Value2"), }, sourceTags: Tags{ - "Key1": aws.String("Value1"), - "Key2": aws.String("Value2"), "Key3": aws.String("Value3"), + "Key2": aws.String("Value2"), + "Key1": aws.String("Value1"), }, - testName: "match subnet of tags from source's multiple tags", + testName: "match subset of tags from source's multiple tags", }, { contains: false, @@ -112,6 +112,16 @@ func TestContainsTags(t *testing.T) { sourceTags: Tags{}, testName: "no match for tag when source has no tags", }, + { + contains: false, + findTags: Tags{}, + sourceTags: Tags{ + "Key1": aws.String("Value1"), + "Key2": aws.String("Value2"), + "Key3": aws.String("Value3"), + }, + testName: "no match when searching for empty tags", + }, { contains: false, findTags: Tags{ @@ -158,7 +168,7 @@ func Test_latticeTagging_FindResourcesByTags_nonTargetGroupTypeError(t *testing. nonTargetGroupResourceType := ResourceTypeService _, err := lt.FindResourcesByTags(ctx, nonTargetGroupResourceType, Tags{}) - assert.NotNil(t, err) + assert.Error(t, err) } func Test_latticeTagging_FindResourcesByTags_ListTagsError(t *testing.T) {