Skip to content

Commit ebfdbb1

Browse files
committed
test(cli): exercise GCP duplicate filtering entry path
1 parent 32e8581 commit ebfdbb1

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

‎cmd/gcp_cud_dedupe_2121_test.go‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,11 @@ func (f *fakeGCPServiceClient) FilterRecommendationsForRecentCommitments(recs []
6060

6161
var _ provider.ServiceClient = (*fakeGCPServiceClient)(nil)
6262

63-
func TestDuplicateChecker_RecentGPCCUDSuppressesFamilyRetry_2121(t *testing.T) {
63+
func TestDuplicateChecker_RecentGCPCUDSuppressesFamilyRetry_2121(t *testing.T) {
6464
ctx := context.Background()
65+
previousWindow := toolCfg.IdempotencyWindowHours
66+
toolCfg.IdempotencyWindowHours = 0
67+
t.Cleanup(func() { toolCfg.IdempotencyWindowHours = previousWindow })
6568

6669
recentCUD := common.Commitment{
6770
Provider: common.ProviderGCP,
@@ -91,10 +94,9 @@ func TestDuplicateChecker_RecentGPCCUDSuppressesFamilyRetry_2121(t *testing.T) {
9194
commitments: []common.Commitment{recentCUD},
9295
}
9396
recs := []common.Recommendation{cudRec("n2-standard-4"), cudRec("n4-standard-4")}
94-
passed, filtered, err := NewDuplicateChecker(0).AdjustRecommendationsForExisting(ctx, recs, client)
95-
require.NoError(t, err)
96-
require.Len(t, filtered, 1, "recent GENERAL_PURPOSE_N2 purchase must suppress the n2 retry")
97-
assert.Equal(t, "n2-standard-4", filtered[0].ResourceType)
98-
require.Len(t, passed, 1, "a different commitment family must not be suppressed")
99-
assert.Equal(t, "n4-standard-4", passed[0].ResourceType)
97+
drops := common.NewDropSummary()
98+
adjusted := checkDuplicates(ctx, recs, client, false, drops)
99+
assert.Equal(t, "Dropped 1 recs: duplicate-dedup=1", drops.FormatOneLine())
100+
require.Len(t, adjusted, 1, "a different commitment family must not be suppressed")
101+
assert.Equal(t, "n4-standard-4", adjusted[0].ResourceType)
100102
}

0 commit comments

Comments
 (0)