@@ -11,6 +11,7 @@ import (
1111
1212 "github.com/cloudposse/atmos/pkg/auth"
1313 "github.com/cloudposse/atmos/pkg/component"
14+ cfg "github.com/cloudposse/atmos/pkg/config"
1415 "github.com/cloudposse/atmos/pkg/hooks"
1516 "github.com/cloudposse/atmos/pkg/schema"
1617)
@@ -39,6 +40,87 @@ func TestHelmBulkCICollectorRecordsAndSortsResults(t *testing.T) {
3940 assert .Equal (t , "+ change" , collector .resultSet ().Results [1 ].Summary ["diff" ])
4041}
4142
43+ func TestHelmBulkCICollectorDeepCopiesNestedSummary (t * testing.T ) {
44+ collector := newHelmBulkCICollector ("apply" )
45+ wait := map [string ]any {"strategy" : "watcher" }
46+ kinds := []string {"Deployment" , "Service" }
47+ summary := map [string ]any {
48+ "release" : map [string ]any {"wait" : wait },
49+ "object_kinds" : kinds ,
50+ }
51+ collector .setSummary (& schema.ConfigAndStacksInfo {Stack : "dev" , ComponentFromArg : "api" }, summary , nil )
52+
53+ wait ["strategy" ] = "legacy"
54+ kinds [0 ] = "Job"
55+ result := collector .resultSet ().Results [0 ]
56+ release := result .Summary ["release" ].(map [string ]any )
57+ assert .Equal (t , "watcher" , release ["wait" ].(map [string ]any )["strategy" ])
58+ assert .Equal (t , []string {"Deployment" , "Service" }, result .Summary ["object_kinds" ])
59+
60+ release ["wait" ].(map [string ]any )["strategy" ] = "mutated"
61+ result .Summary ["object_kinds" ].([]string )[1 ] = "ConfigMap"
62+ retained := collector .resultSet ().Results [0 ].Summary
63+ assert .Equal (t , "watcher" , retained ["release" ].(map [string ]any )["wait" ].(map [string ]any )["strategy" ])
64+ assert .Equal (t , []string {"Deployment" , "Service" }, retained ["object_kinds" ])
65+ }
66+
67+ type helmBulkGraphTestProvider struct {
68+ failComponent string
69+ }
70+
71+ func (p * helmBulkGraphTestProvider ) GetType () string { return cfg .HelmComponentType }
72+ func (p * helmBulkGraphTestProvider ) GetGroup () string { return "test" }
73+ func (p * helmBulkGraphTestProvider ) GetBasePath (* schema.AtmosConfiguration ) string { return "" }
74+ func (p * helmBulkGraphTestProvider ) ListComponents (context.Context , string , map [string ]any ) ([]string , error ) {
75+ return nil , nil
76+ }
77+ func (p * helmBulkGraphTestProvider ) ValidateComponent (map [string ]any ) error { return nil }
78+ func (p * helmBulkGraphTestProvider ) Execute (ctx * component.ExecutionContext ) error {
79+ if ctx .Component == p .failComponent {
80+ return errors .New ("operation failed" )
81+ }
82+ return nil
83+ }
84+ func (p * helmBulkGraphTestProvider ) GenerateArtifacts (* component.ExecutionContext ) error { return nil }
85+ func (p * helmBulkGraphTestProvider ) GetAvailableCommands () []string { return nil }
86+
87+ func TestHelmBulkCICollectorRecordsDependencyBlockedComponents (t * testing.T ) {
88+ collector := newHelmBulkCICollector ("apply" )
89+ provider := & bulkCollectingProvider {
90+ ComponentProvider : & helmBulkGraphTestProvider {failComponent : "base" },
91+ collector : collector ,
92+ }
93+ stacks := map [string ]any {
94+ "dev" : map [string ]any {
95+ cfg .ComponentsSectionName : map [string ]any {
96+ cfg .HelmComponentType : map [string ]any {
97+ "base" : map [string ]any {},
98+ "api" : map [string ]any {
99+ cfg .SettingsSectionName : map [string ]any {"depends_on" : []any {"base" }},
100+ },
101+ },
102+ },
103+ },
104+ }
105+
106+ err := component .ExecuteGraph (context .Background (), & component.GraphExecutionOptions {
107+ Provider : provider ,
108+ Info : & schema.ConfigAndStacksInfo {},
109+ Stacks : stacks ,
110+ ComponentType : cfg .HelmComponentType ,
111+ SubCommand : "apply" ,
112+ })
113+ require .Error (t , err )
114+
115+ results := collector .resultSet ().Results
116+ require .Len (t , results , 2 )
117+ assert .Equal (t , "api" , results [0 ].Component )
118+ assert .Equal (t , "skipped" , results [0 ].Status )
119+ assert .False (t , results [0 ].Processed )
120+ assert .Equal (t , "base" , results [1 ].Component )
121+ assert .Equal (t , "failed" , results [1 ].Status )
122+ }
123+
42124func TestHelmBulkCICollectorUsesProcessedComponentIdentity (t * testing.T ) {
43125 collector := newHelmBulkCICollector ("plan" )
44126 info := schema.ConfigAndStacksInfo {Stack : "dev" , ComponentFromArg : "apps/app" }
0 commit comments