From da4233b0c24dbc4e7d5f8273c41e2c830f4b03cd Mon Sep 17 00:00:00 2001 From: Jaz Date: Fri, 2 Feb 2024 15:15:50 -0500 Subject: [PATCH] fix --- internal/extinctions/extinctions.go | 2 +- internal/references/builder_test.go | 30 ++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/internal/extinctions/extinctions.go b/internal/extinctions/extinctions.go index 98434814..6594072b 100644 --- a/internal/extinctions/extinctions.go +++ b/internal/extinctions/extinctions.go @@ -11,7 +11,7 @@ import ( func CheckExtinctions(opts options.Options, builder *refs.ReferenceSummaryBuilder) error { gha.StartLogGroup("Checking for extinctions...") defer gha.EndLogGroup() - flagKeys := make([]string, 0, len(builder.RemovedFlagKeys())) + flagKeys := builder.RemovedFlagKeys() matcher, err := search.GetMatcher(opts, flagKeys, nil) if err != nil { diff --git a/internal/references/builder_test.go b/internal/references/builder_test.go index 95ee64b1..52b53244 100644 --- a/internal/references/builder_test.go +++ b/internal/references/builder_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/assert" ) -func TestBuilder(t *testing.T) { +func TestBuilder_Build(t *testing.T) { ref := ReferenceSummaryBuilder{ flagsAdded: map[string][]string{ "flag1": {"alias1"}, @@ -35,3 +35,31 @@ func TestBuilder(t *testing.T) { assert.Len(t, built.FlagsRemoved, 2) assert.Len(t, built.ExtinctFlags, 1) } + +func TestBuilder_RemovedFlagKeys(t *testing.T) { + ref := ReferenceSummaryBuilder{ + flagsAdded: map[string][]string{ + "flag1": {"alias1"}, + "flag2": {"alias2"}, + }, + flagsRemoved: map[string][]string{ + "flag2": {}, + "flag3": {"alias3"}, + "flag4": {"alias4"}, + }, + flagsFoundAtHead: map[string]struct{}{ + "flag3": {}, + }, + foundFlags: map[string]struct{}{ + "flag1": {}, + "flag2": {}, + "flag3": {}, + "flag4": {}, + }, + includeExtinctions: true, + } + + keys := ref.RemovedFlagKeys() + + assert.Len(t, keys, 3) +}