@@ -63,16 +63,16 @@ func TestAppInstallManager_Install(t *testing.T) {
6363 },
6464 }
6565
66- // Create InstallableHelmCharts with pre-processed values
66+ // Create InstallableHelmCharts with weights - should already be sorted at this stage
6767 installableCharts := []types.InstallableHelmChart {
68- createTestInstallableHelmChart (t , "nginx-chart" , "1.0.0" , "web-server" , "web" , map [string ]any {
68+ createTestInstallableHelmChart (t , "nginx-chart" , "1.0.0" , "web-server" , "web" , 10 , map [string ]any {
6969 "image" : map [string ]any {
7070 "repository" : "nginx" ,
7171 "tag" : "latest" ,
7272 },
7373 "replicas" : 3 ,
7474 }),
75- createTestInstallableHelmChart (t , "postgres-chart" , "2.0.0" , "database" , "data" , map [string ]any {
75+ createTestInstallableHelmChart (t , "postgres-chart" , "2.0.0" , "database" , "data" , 20 , map [string ]any {
7676 "database" : map [string ]any {
7777 "host" : "postgres.example.com" ,
7878 "password" : "secret" ,
@@ -84,7 +84,7 @@ func TestAppInstallManager_Install(t *testing.T) {
8484 mockHelmClient := & helm.MockClient {}
8585
8686 // Chart 1 installation (nginx chart)
87- mockHelmClient .On ("Install" , mock .Anything , mock .MatchedBy (func (opts helm.InstallOptions ) bool {
87+ nginxCall := mockHelmClient .On ("Install" , mock .Anything , mock .MatchedBy (func (opts helm.InstallOptions ) bool {
8888 if opts .ReleaseName != "web-server" {
8989 return false
9090 }
@@ -99,7 +99,7 @@ func TestAppInstallManager_Install(t *testing.T) {
9999 })).Return (& helmrelease.Release {Name : "web-server" }, nil )
100100
101101 // Chart 2 installation (database chart)
102- mockHelmClient .On ("Install" , mock .Anything , mock .MatchedBy (func (opts helm.InstallOptions ) bool {
102+ databaseCall := mockHelmClient .On ("Install" , mock .Anything , mock .MatchedBy (func (opts helm.InstallOptions ) bool {
103103 if opts .ReleaseName != "database" {
104104 return false
105105 }
@@ -113,6 +113,12 @@ func TestAppInstallManager_Install(t *testing.T) {
113113 return false
114114 })).Return (& helmrelease.Release {Name : "database" }, nil )
115115
116+ // Verify installation order
117+ mock .InOrder (
118+ nginxCall ,
119+ databaseCall ,
120+ )
121+
116122 // Create mock installer with detailed verification of config values
117123 mockInstaller := & MockKotsCLIInstaller {}
118124 mockInstaller .On ("Install" , mock .MatchedBy (func (opts kotscli.InstallOptions ) bool {
@@ -190,7 +196,7 @@ func TestAppInstallManager_Install(t *testing.T) {
190196
191197 t .Run ("Install updates status correctly" , func (t * testing.T ) {
192198 installableCharts := []types.InstallableHelmChart {
193- createTestInstallableHelmChart (t , "monitoring-chart" , "1.0.0" , "prometheus" , "monitoring" , map [string ]any {"key" : "value" }),
199+ createTestInstallableHelmChart (t , "monitoring-chart" , "1.0.0" , "prometheus" , "monitoring" , 0 , map [string ]any {"key" : "value" }),
194200 }
195201
196202 // Create mock helm client
@@ -239,7 +245,7 @@ func TestAppInstallManager_Install(t *testing.T) {
239245
240246 t .Run ("Install handles errors correctly" , func (t * testing.T ) {
241247 installableCharts := []types.InstallableHelmChart {
242- createTestInstallableHelmChart (t , "logging-chart" , "1.0.0" , "fluentd" , "logging" , map [string ]any {"key" : "value" }),
248+ createTestInstallableHelmChart (t , "logging-chart" , "1.0.0" , "fluentd" , "logging" , 0 , map [string ]any {"key" : "value" }),
243249 }
244250
245251 // Create mock helm client that fails
@@ -372,7 +378,7 @@ type: application
372378}
373379
374380// Helper functions to create test data that can be reused across test cases
375- func createTestHelmChartCR (name , releaseName , namespace string ) * kotsv1beta2.HelmChart {
381+ func createTestHelmChartCR (name , releaseName , namespace string , weight int64 ) * kotsv1beta2.HelmChart {
376382 return & kotsv1beta2.HelmChart {
377383 TypeMeta : metav1.TypeMeta {
378384 APIVersion : "kots.io/v1beta2" ,
@@ -384,14 +390,15 @@ func createTestHelmChartCR(name, releaseName, namespace string) *kotsv1beta2.Hel
384390 Spec : kotsv1beta2.HelmChartSpec {
385391 ReleaseName : releaseName ,
386392 Namespace : namespace ,
393+ Weight : weight ,
387394 },
388395 }
389396}
390397
391- func createTestInstallableHelmChart (t * testing.T , chartName , chartVersion , releaseName , namespace string , values map [string ]any ) types.InstallableHelmChart {
398+ func createTestInstallableHelmChart (t * testing.T , chartName , chartVersion , releaseName , namespace string , weight int64 , values map [string ]any ) types.InstallableHelmChart {
392399 return types.InstallableHelmChart {
393400 Archive : createTestChartArchive (t , chartName , chartVersion ),
394401 Values : values ,
395- CR : createTestHelmChartCR (chartName , releaseName , namespace ),
402+ CR : createTestHelmChartCR (chartName , releaseName , namespace , weight ),
396403 }
397404}
0 commit comments