Skip to content

Commit 0af4574

Browse files
committed
fix: omit empty terraform test section
1 parent 3640330 commit 0af4574

3 files changed

Lines changed: 17 additions & 3 deletions

File tree

internal/exec/stack_processor_merge.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,9 @@ func mergeComponentConfigurations(atmosConfig *schema.AtmosConfiguration, opts *
520520
comp[cfg.RequiredProvidersSectionName] = finalComponentRequiredProviders
521521
comp[cfg.RequiredVersionSectionName] = finalComponentRequiredVersion
522522
comp[cfg.HooksSectionName] = finalComponentHooks
523-
comp[cfg.TestSectionName] = finalComponentTest
523+
if len(finalComponentTest) > 0 {
524+
comp[cfg.TestSectionName] = finalComponentTest
525+
}
524526
comp[cfg.GenerateSectionName] = finalComponentGenerate
525527
comp[cfg.BackendTypeSectionName] = finalComponentBackendType
526528
comp[cfg.BackendSectionName] = finalComponentBackend

internal/exec/stack_processor_merge_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,20 @@ func TestMergeComponentConfigurations_TerraformTestSection(t *testing.T) {
441441
assert.Equal(t, "base", testVars["base_only"])
442442
}
443443

444+
func TestMergeComponentConfigurations_TerraformTestSectionOmittedWhenEmpty(t *testing.T) {
445+
atmosCfg := &schema.AtmosConfiguration{}
446+
opts := ComponentProcessorOptions{
447+
ComponentType: cfg.TerraformComponentType,
448+
Component: "app",
449+
AtmosConfig: atmosCfg,
450+
}
451+
res := minimalComponentResult()
452+
453+
comp, err := mergeComponentConfigurations(atmosCfg, &opts, res)
454+
require.NoError(t, err)
455+
assert.NotContains(t, comp, cfg.TestSectionName)
456+
}
457+
444458
// TestMergeComponentConfigurations_Retry covers the per-component retry merge added by
445459
// the component-retry feature: base → component → overrides precedence on scalars, and
446460
// list-append on the `conditions:` slice (the existing deep-merge semantic). It also

internal/exec/stack_processor_process_stacks_helpers_extraction.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,6 @@ func extractComponentSections(opts *ComponentProcessorOptions, result *Component
118118
return fmt.Errorf("%w: 'components.%s.%s.test' in the file '%s'", errUtils.ErrInvalidConfig, opts.ComponentType, opts.Component, opts.StackName)
119119
}
120120
result.ComponentTest = componentTest
121-
} else {
122-
result.ComponentTest = make(map[string]any, componentSmallMapCapacity)
123121
}
124122
}
125123

0 commit comments

Comments
 (0)