Skip to content

Commit 77fd2fc

Browse files
committed
chore: Fixing TestWorktreeDiscovery_Stacks
1 parent 2a33ca2 commit 77fd2fc

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

internal/discovery/worktreediscovery_test.go

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -876,8 +876,12 @@ unit "unit_to_be_untouched" {
876876
fromWorktree := worktreePair.FromWorktree.Path
877877
toWorktree := worktreePair.ToWorktree.Path
878878

879-
// All paths are worktree paths - no translation needed
880-
assert.ElementsMatch(t, components, component.Components{
879+
// All paths are worktree paths - no translation needed.
880+
//
881+
// NOTE: Discovery may attach additional state (e.g., partially-parsed configs) that isn't relevant
882+
// to this test's intent. We normalize the discovered components by clearing that state so a simple
883+
// deep comparison remains stable over time.
884+
expected := component.Components{
881885
// Stacks
882886
component.NewStack(filepath.Join(toWorktree, stackToBeAddedRel)).WithDiscoveryContext(
883887
&component.DiscoveryContext{
@@ -976,7 +980,22 @@ unit "unit_to_be_untouched" {
976980
Args: []string{"-destroy"},
977981
},
978982
),
979-
})
983+
}
984+
985+
for _, c := range components {
986+
switch v := c.(type) {
987+
case *component.Unit:
988+
// Normalize fields that may be populated during discovery, but are irrelevant to this test's assertions.
989+
v.StoreConfig(nil)
990+
// Normalize slices so deep equality is stable (nil vs empty differs in reflect.DeepEqual).
991+
v.SetReading()
992+
case *component.Stack:
993+
v.StoreConfig(nil)
994+
v.SetReading()
995+
}
996+
}
997+
998+
assert.ElementsMatch(t, components, expected)
980999
}
9811000

9821001
// TestWorktreeDiscoveryDetectsFileRename verifies that renaming a file within a unit

internal/runner/runnerpool/runner.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ func resolveUnitsFromDiscovery(
159159
}
160160

161161
basePath := stack.Path()
162+
162163
configFileName := config.DefaultTerragruntConfigPath
163164
if stack.Execution != nil && stack.Execution.TerragruntOptions != nil {
164165
configFileName = filepath.Base(stack.Execution.TerragruntOptions.TerragruntConfigPath)

0 commit comments

Comments
 (0)