Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/multi_service_csv.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ func formatIntOrBlank(v int) string {
// extractFamily returns the CSV Family value: the instance-family prefix
// (e.g. "db.r7g") for an RDS recommendation, or the plan's instance family
// for a Savings Plan row; empty for any other service. Operators use it to
// group rows by family-NU bucket and see which recs share a size-flex family.
// group rows by family (for RDS, the family-NU bucket).
func extractFamily(rec common.Recommendation) string {
if sp, ok := rec.Details.(*common.SavingsPlanDetails); ok && sp != nil {
return sp.InstanceFamily
Expand Down
9 changes: 6 additions & 3 deletions cmd/multi_service_csv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,9 @@ func TestFormatRecurringMonthlyOrBlank(t *testing.T) {
}
}

// TestExtractRDSFamily covers the family-prefix extraction used by the
// CSV writer to group rows by size-flex family.
func TestExtractRDSFamily(t *testing.T) {
// TestExtractFamily covers the CSV Family column: the RDS family prefix and
// the Savings Plan instance family.
func TestExtractFamily(t *testing.T) {
tests := []struct {
name string
rec common.Recommendation
Expand All @@ -455,6 +455,9 @@ func TestExtractRDSFamily(t *testing.T) {
{"ElastiCache ignored", common.Recommendation{Service: common.ServiceElastiCache, ResourceType: "cache.t3.micro"}, ""},
// Malformed RDS type.
{"RDS bare type", common.Recommendation{Service: common.ServiceRDS, ResourceType: "db.r7g"}, ""},
{"EC2 Instance SP", common.Recommendation{Service: common.ServiceSavingsPlansEC2Instance, Details: &common.SavingsPlanDetails{InstanceFamily: "m5"}}, "m5"},
{"Compute SP has no family", common.Recommendation{Service: common.ServiceSavingsPlansCompute, Details: &common.SavingsPlanDetails{}}, ""},
{"nil SP details", common.Recommendation{Service: common.ServiceSavingsPlansCompute, Details: (*common.SavingsPlanDetails)(nil)}, ""},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/multi_service_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ func fetchRecommendationsForRegion(
// and are left empty.
func stampSavingsPlanRegions(recs []common.Recommendation) {
for i := range recs {
if recs[i].CommitmentType == common.CommitmentSavingsPlan && recs[i].Region == "" {
if recs[i].CommitmentType == common.CommitmentSavingsPlan {
recs[i].Region = awsprovider.EffectiveRegion(recs[i])
}
}
Expand Down
5 changes: 0 additions & 5 deletions cmd/savings_plan_region_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,10 @@ import (
"github.com/stretchr/testify/require"
)

// testAccountID is split so the 12-digit literal does not trip the git-secrets
// account-id pattern, which .gitallowed only permits on specific lines.
const testAccountID = "1234" + "56789012"

func ec2InstanceSPRow() common.Recommendation {
return common.Recommendation{
Provider: common.ProviderAWS, Service: common.ServiceSavingsPlansEC2Instance,
CommitmentType: common.CommitmentSavingsPlan,
Account: testAccountID,
Term: "1yr", PaymentOption: "no-upfront",
Details: &common.SavingsPlanDetails{PlanType: "EC2Instance", HourlyCommitment: 2.697, InstanceFamily: "m5", Region: "eu-west-2"},
}
Expand Down
Loading