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
20 changes: 10 additions & 10 deletions cmd/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ func TestApplyCountOverride(t *testing.T) {
tests := []struct {
name string
recs []common.Recommendation
overrideCount int32
expectedCounts []int
overrideCount int32
}{
{
name: "Override with positive value",
Expand Down Expand Up @@ -252,8 +252,8 @@ func TestApplyCoverage(t *testing.T) {
tests := []struct {
name string
recs []common.Recommendation
coverage float64
expectedCounts []int
coverage float64
expectedLen int
}{
{
Expand Down Expand Up @@ -383,8 +383,8 @@ func TestAdjustRecommendationsForExisting(t *testing.T) {
name string
inputRecs []common.Recommendation
existingRIs []common.Commitment
expectedLen int
expectedCounts []int
expectedLen int
}{
{
name: "No existing RIs - all recommendations kept",
Expand Down Expand Up @@ -490,8 +490,8 @@ func TestAdjustRecommendationsForExisting(t *testing.T) {
func TestGetRecommendationDescription(t *testing.T) {
tests := []struct {
name string
rec common.Recommendation
expected string
rec common.Recommendation
}{
{
name: "RDS recommendation with database details",
Expand Down Expand Up @@ -570,8 +570,8 @@ func TestNormalizeEngineName(t *testing.T) {
func TestGetEngineFromRecommendation(t *testing.T) {
tests := []struct {
name string
rec common.Recommendation
expected string
rec common.Recommendation
}{
{
name: "DatabaseDetails value type",
Expand Down Expand Up @@ -627,7 +627,7 @@ func TestGetEngineFromRecommendation(t *testing.T) {

// confirmPurchaseWithInput is a testable variant of ConfirmPurchase that reads
// from the provided reader rather than os.Stdin, allowing stdin to be mocked in tests.
func confirmPurchaseWithInput(totalInstances int, totalCost float64, skipConfirmation bool, input string) bool {
func confirmPurchaseWithInput(skipConfirmation bool, input string) bool {
if skipConfirmation {
return true
}
Expand Down Expand Up @@ -693,7 +693,7 @@ func TestConfirmPurchaseInput(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := confirmPurchaseWithInput(1, 10.0, false, tt.input)
result := confirmPurchaseWithInput(false, tt.input)
assert.Equal(t, tt.expected, result)
})
}
Expand All @@ -706,8 +706,8 @@ func TestAdjustRecommendationsForExistingRIsEdgeCases(t *testing.T) {
name string
inputRecs []common.Recommendation
existingRIs []common.Commitment
expectedLen int
expectedCounts []int
expectedLen int
}{
{
name: "Multiple RIs same instance type different regions",
Expand Down Expand Up @@ -771,9 +771,9 @@ func TestApplyInstanceLimit(t *testing.T) {
tests := []struct {
name string
recs []common.Recommendation
maxInstances int32
expectedLen int
expectedCounts []int
expectedLen int
maxInstances int32
}{
{
name: "No limit - all recommendations kept",
Expand Down
50 changes: 25 additions & 25 deletions cmd/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ func TestGetAllServices(t *testing.T) {
func TestGeneratePurchaseID(t *testing.T) {
tests := []struct {
name string
rec common.Recommendation
region string
expectedPrefix string
rec common.Recommendation
index int
isDryRun bool
coverage float64
expectedPrefix string
isDryRun bool
}{
{
name: "RDS Recommendation - dry run",
Expand Down Expand Up @@ -401,11 +401,11 @@ func TestGeneratePurchaseIDComprehensive(t *testing.T) {

tests := []struct {
name string
rec common.Recommendation
region string
isDryRun bool
rec common.Recommendation
expectedContains []string
expectedNotContains []string
isDryRun bool
}{
{
name: "RDS with account name and engine",
Expand Down Expand Up @@ -617,15 +617,15 @@ func TestGeneratePurchaseIDCoverageVariations(t *testing.T) {

tests := []struct {
name string
coverage float64
expectedCoverage string
coverage float64
}{
{"Coverage 0%", 0.0, "0pct"},
{"Coverage 50%", 50.0, "50pct"},
{"Coverage 75.5%", 75.5, "76pct"}, // Rounds to nearest integer
{"Coverage 99%", 99.0, "99pct"},
{"Coverage 100%", 100.0, "100pct"},
{"Coverage 33.3%", 33.3, "33pct"},
{"Coverage 0%", "0pct", 0.0},
{"Coverage 50%", "50pct", 50.0},
{"Coverage 75.5%", "76pct", 75.5}, // Rounds to nearest integer
{"Coverage 99%", "99pct", 99.0},
{"Coverage 100%", "100pct", 100.0},
{"Coverage 33.3%", "33pct", 33.3},
}

for _, tt := range tests {
Expand Down Expand Up @@ -685,12 +685,12 @@ func TestFilterFlagValidation(t *testing.T) {

tests := []struct {
name string
errorContains string
includeRegions []string
excludeRegions []string
includeInstanceTypes []string
excludeInstanceTypes []string
expectError bool
errorContains string
}{
{
name: "No conflicts",
Expand Down Expand Up @@ -770,9 +770,9 @@ func TestCreateServiceClientAllServices(t *testing.T) {
func TestValidateFlags(t *testing.T) {
tests := []struct {
name string
setPayment string
setCoverage float64
setTerm int
setPayment string
expectError bool
}{
{
Expand Down Expand Up @@ -846,21 +846,21 @@ func TestValidateFlagsExtended(t *testing.T) {
}()

tests := []struct {
name string
setCoverage float64
setTerm int
setPayment string
setMaxInstances int32
setCSVOutput string
setCSVInput string
setCSVOutput string
errorContains string
setPayment string
name string
setIncludeEngines []string
setExcludeEngines []string
setIncludeAccounts []string
setExcludeAccounts []string
setIncludeAccounts []string
setExcludeEngines []string
setIncludeTypes []string
setExcludeTypes []string
setCoverage float64
setTerm int
setMaxInstances int32
expectError bool
errorContains string
}{
// Coverage boundary tests
{
Expand Down Expand Up @@ -1104,8 +1104,8 @@ func TestSanitizeAccountName(t *testing.T) {
func TestGeneratePurchaseID_EdgeCases(t *testing.T) {
tests := []struct {
name string
rec common.Recommendation
region string
rec common.Recommendation
index int
isDryRun bool
}{
Expand Down Expand Up @@ -1179,9 +1179,9 @@ func TestGeneratePurchaseID_EdgeCases(t *testing.T) {
func TestValidateInstanceTypes(t *testing.T) {
tests := []struct {
name string
errorContains string
instanceTypes []string
expectError bool
errorContains string
}{
{
name: "Empty slice is valid",
Expand Down
2 changes: 1 addition & 1 deletion cmd/multi_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ func filterAndAdjustRecommendations(recommendations []common.Recommendation, csv

// Apply filters (empty currentRegion since we're processing from CSV, not iterating regions)
originalCount := len(recommendations)
recommendations = applyFilters(recommendations, cfg, instanceVersions, versionInfo, "")
recommendations = applyFilters(recommendations, &cfg, instanceVersions, versionInfo, "")
if len(recommendations) < originalCount {
AppLogger.Printf("🔍 After filters: %d recommendations (filtered out %d)\n", len(recommendations), originalCount-len(recommendations))
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/multi_service_engine_versions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (

func TestAdjustRecommendationForExcludedVersions(t *testing.T) {
tests := []struct {
name string
recommendation common.Recommendation
versionInfo map[string]MajorEngineVersionInfo
instanceVersions map[string][]InstanceEngineVersion
name string
recommendation common.Recommendation
expectedCount int
expectedAdjusted bool
}{
Expand Down Expand Up @@ -313,7 +313,7 @@ func TestExtractMajorVersion_Additional(t *testing.T) {
}
}

// Comprehensive tests for extractMajorVersion function
// Comprehensive tests for extractMajorVersion function.
func TestExtractMajorVersion_Comprehensive(t *testing.T) {
tests := []struct {
name string
Expand Down Expand Up @@ -502,10 +502,10 @@ func TestIsInExtendedSupport(t *testing.T) {
futureDate := now.AddDate(3, 0, 0)

tests := []struct {
versionInfo map[string]MajorEngineVersionInfo
name string
engine string
version string
versionInfo map[string]MajorEngineVersionInfo
expected bool
}{
{
Expand Down
Loading
Loading